Documentation
¶
Index ¶
- type Context
- func (dc *Context) ArcTo(x1, y1, x2, y2, radius float64)
- func (dc *Context) BeginPath()
- func (dc *Context) Clear()
- func (dc *Context) ClearPath()
- func (dc *Context) Clip()
- func (dc *Context) ClipPreserve()
- func (dc *Context) ClosePath()
- func (dc *Context) CurrentPoint() (float64, float64, bool)
- func (dc *Context) DrawEllipticalArc(x, y, rx, ry, angle1, angle2 float64)
- func (dc *Context) DrawImageAnchored(im image.Image, x, y int, ax, ay float64)
- func (dc *Context) DrawLine(x1, y1, x2, y2 float64)
- func (dc *Context) DrawPoint(x, y float64)
- func (dc *Context) DrawStringAnchored(s string, x, y, ax, ay float64)
- func (dc *Context) Fill()
- func (dc *Context) FillAndStroke()
- func (dc *Context) FillPreserve()
- func (dc *Context) FontSize() float64
- func (dc *Context) Height() float64
- func (dc *Context) Identity()
- func (dc *Context) Image() image.Image
- func (dc *Context) LineTo(x, y float64)
- func (dc *Context) MeasureString(s string) (w, h float64)
- func (dc *Context) MoveTo(x, y float64)
- func (dc *Context) Pop()
- func (dc *Context) Push()
- func (dc *Context) QuadraticTo(x1, y1, x2, y2 float64)
- func (dc *Context) ResetClip()
- func (dc *Context) Rotate(angle float64)
- func (dc *Context) Scale(x, y float64)
- func (dc *Context) SetFillColor(r, g, b, a int)
- func (dc *Context) SetFillRule(fillRule gg.FillRule)
- func (dc *Context) SetFillStyle(pattern gg.Pattern)
- func (dc *Context) SetFont(font *truetype.Font)
- func (dc *Context) SetFontSize(points float64)
- func (dc *Context) SetLineCap(lineCap gg.LineCap)
- func (dc *Context) SetLineDash(dashes ...float64)
- func (dc *Context) SetLineDashOffset(offset float64)
- func (dc *Context) SetLineJoin(lineJoin gg.LineJoin)
- func (dc *Context) SetPixelColor(c color.Color, x, y int)
- func (dc *Context) SetStrokeColor(r, g, b, a int)
- func (dc *Context) SetStrokeStyle(pattern gg.Pattern)
- func (dc *Context) SetStrokeWeight(lineWidth float64)
- func (dc *Context) Stroke()
- func (dc *Context) StrokeWeight() float64
- func (dc *Context) TransformPoint(x, y float64) (tx, ty float64)
- func (dc *Context) Translate(x, y float64)
- func (dc *Context) Width() float64
- type Point
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context implements the graphic context for drawing on images
func NewContextForRGBA ¶
NewContextForRGBA prepares a context for rendering onto the specified image. No copy is made.
func (*Context) ArcTo ¶
ArcTo adds a circular arc to the current sub-path, using the given control points and radius. The arc is automatically connected to the path's latest point with a straight line, if necessary for the specified parameters.
This method is commonly used for making rounded corners. https://github.com/WebKit/webkit/blob/main/Source/WebCore/platform/graphics/cairo/PathCairo.cpp#L204
func (*Context) BeginPath ¶
func (dc *Context) BeginPath()
BeginPath starts a new subpath within the current path. There is no current point after this operation.
func (*Context) Clear ¶
func (dc *Context) Clear()
Clear fills the entire image with the current fill color.
func (*Context) ClearPath ¶
func (dc *Context) ClearPath()
ClearPath clears the current path. There is no current point after this operation.
func (*Context) Clip ¶
func (dc *Context) Clip()
Clip updates the clipping region by intersecting the current clipping region with the current path as it would be filled by dc.Fill(). The path is cleared after this operation.
func (*Context) ClipPreserve ¶
func (dc *Context) ClipPreserve()
ClipPreserve updates the clipping region by intersecting the current clipping region with the current path as it would be filled by dc.Fill(). The path is preserved after this operation.
func (*Context) ClosePath ¶
func (dc *Context) ClosePath()
ClosePath adds a line segment from the current point to the beginning of the current subpath. If there is no current point, this is a no-op.
func (*Context) CurrentPoint ¶
CurrentPoint returns the current point and if there is a current point. The point will have been transformed by the context's transformation matrix.
func (*Context) DrawEllipticalArc ¶
DrawEllipticalArc draws an elliptical arc
func (*Context) DrawImageAnchored ¶
DrawImageAnchored draws the specified image at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the image. Use ax=0.5, ay=0.5 to center the image at the specified point.
func (*Context) DrawStringAnchored ¶
DrawStringAnchored draws the specified text at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the text. Use ax=0.5, ay=0.5 to center the text at the specified point.
func (*Context) Fill ¶
func (dc *Context) Fill()
Fill fills the current path with the current color. Open subpaths are implicity closed. The path is cleared after this operation.
func (*Context) FillAndStroke ¶
func (dc *Context) FillAndStroke()
FillAndStroke first fills the paths and than strokes them
func (*Context) FillPreserve ¶
func (dc *Context) FillPreserve()
FillPreserve fills the current path with the current color. Open subpaths are implicity closed. The path is preserved after this operation.
func (*Context) Identity ¶
func (dc *Context) Identity()
Identity resets the current transformation matrix to the identity matrix. This results in no translating, scaling, rotating, or shearing.
func (*Context) LineTo ¶
LineTo adds a line segment to the current path starting at the current point. If there is no current point, it is equivalent to MoveTo(x, y)
func (*Context) MeasureString ¶
MeasureString returns the rendered width and height of the specified text given the current font face.
func (*Context) MoveTo ¶
MoveTo starts a new subpath within the current path starting at the specified point.
func (*Context) Pop ¶
func (dc *Context) Pop()
Pop restores the last saved context state from the stack.
func (*Context) Push ¶
func (dc *Context) Push()
Push saves the current state of the context for later retrieval. These can be nested.
func (*Context) QuadraticTo ¶
QuadraticTo adds a quadratic bezier curve to the current path starting at the current point. If there is no current point, it first performs MoveTo(x1, y1)
func (*Context) Rotate ¶
Rotate updates the current matrix with a anticlockwise rotation. Rotation occurs about the origin. Angle is specified in radians.
func (*Context) Scale ¶
Scale updates the current matrix with a scaling factor. Scaling occurs about the origin.
func (*Context) SetFillColor ¶
SetFillColor sets the current stroke color. r, g, b, a values should be between 0 and 255, inclusive.
func (*Context) SetFillRule ¶
SetFillRule sets the current fill rule
func (*Context) SetFillStyle ¶
SetFillStyle sets current fill style
func (*Context) SetFontSize ¶
SetFontSize sets the current font size
func (*Context) SetLineCap ¶
SetLineCap sets the current line cap
func (*Context) SetLineDash ¶
SetLineDash sets the current dash
func (*Context) SetLineDashOffset ¶
SetLineDashOffset sets the initial offset into the dash pattern
func (*Context) SetLineJoin ¶
SetLineJoin sets the current line join
func (*Context) SetPixelColor ¶
SetPixelColor sets the color of the specified pixel using the current color.
func (*Context) SetStrokeColor ¶
SetStrokeColor sets the current stroke color. r, g, b, a values should be between 0 and 255, inclusive.
func (*Context) SetStrokeStyle ¶
SetStrokeStyle sets current stroke style
func (*Context) SetStrokeWeight ¶
SetStrokeWeight sets the lineWidth.
func (*Context) Stroke ¶
func (dc *Context) Stroke()
Stroke strokes the current path with the current color, line width, line cap, line join and dash settings. The path is cleared after this operation.
func (*Context) StrokeWeight ¶
StrokeWeight returns the current line width
func (*Context) TransformPoint ¶
TransformPoint multiplies the specified point by the current matrix, returning a transformed position.
type Point ¶
type Point struct {
X, Y float64
}
Point holds a coordinates pair
func CubicBezier ¶
CubicBezier returns points for a cubic bezier curve
func QuadraticBezier ¶
QuadraticBezier returns points for a quadratic bezier curve