type LineCap … const LineCapRound … const LineCapButt … const LineCapSquare … type LineJoin … const LineJoinRound … const LineJoinBevel … type FillRule … const FillRuleWinding … const FillRuleEvenOdd … type Align … const AlignLeft … const AlignCenter … const AlignRight … var defaultFillStyle … var defaultStrokeStyle … type Context … // NewContext creates a new image.RGBA with the specified width and height // and prepares a context for rendering onto that image. func NewContext(width, height int) *Context { … } // NewContextForImage copies the specified image into a new image.RGBA // and prepares a context for rendering onto that image. func NewContextForImage(im image.Image) *Context { … } // NewContextForRGBA prepares a context for rendering onto the specified image. // No copy is made. func NewContextForRGBA(im *image.RGBA) *Context { … } // GetCurrentPoint will return the current point and if there is a current point. // The point will have been transformed by the context's transformation matrix. func (dc *Context) GetCurrentPoint() (Point, bool) { … } // Image returns the image that has been drawn by this context. func (dc *Context) Image() image.Image { … } // Width returns the width of the image in pixels. func (dc *Context) Width() int { … } // Height returns the height of the image in pixels. func (dc *Context) Height() int { … } // SavePNG encodes the image as a PNG and writes it to disk. func (dc *Context) SavePNG(path string) error { … } // EncodePNG encodes the image as a PNG and writes it to the provided io.Writer. func (dc *Context) EncodePNG(w io.Writer) error { … } // SetDash sets the current dash pattern to use. Call with zero arguments to // disable dashes. The values specify the lengths of each dash, with // alternating on and off lengths. func (dc *Context) SetDash(dashes ...float64) { … } // SetDashOffset sets the initial offset into the dash pattern to use when // stroking dashed paths. func (dc *Context) SetDashOffset(offset float64) { … } func (dc *Context) SetLineWidth(lineWidth float64) { … } func (dc *Context) SetLineCap(lineCap LineCap) { … } func (dc *Context) SetLineCapRound() { … } func (dc *Context) SetLineCapButt() { … } func (dc *Context) SetLineCapSquare() { … } func (dc *Context) SetLineJoin(lineJoin LineJoin) { … } func (dc *Context) SetLineJoinRound() { … } func (dc *Context) SetLineJoinBevel() { … } func (dc *Context) SetFillRule(fillRule FillRule) { … } func (dc *Context) SetFillRuleWinding() { … } func (dc *Context) SetFillRuleEvenOdd() { … } func (dc *Context) setFillAndStrokeColor(c color.Color) { … } // SetFillStyle sets current fill style func (dc *Context) SetFillStyle(pattern Pattern) { … } // SetStrokeStyle sets current stroke style func (dc *Context) SetStrokeStyle(pattern Pattern) { … } // SetColor sets the current color(for both fill and stroke). func (dc *Context) SetColor(c color.Color) { … } // SetHexColor sets the current color using a hex string. The leading pound // sign (#) is optional. Both 3- and 6-digit variations are supported. 8 digits // may be provided to set the alpha value as well. func (dc *Context) SetHexColor(x string) { … } // SetRGBA255 sets the current color. r, g, b, a values should be between 0 and // 255, inclusive. func (dc *Context) SetRGBA255(r, g, b, a int) { … } // SetRGB255 sets the current color. r, g, b values should be between 0 and 255, // inclusive. Alpha will be set to 255 (fully opaque). func (dc *Context) SetRGB255(r, g, b int) { … } // SetRGBA sets the current color. r, g, b, a values should be between 0 and 1, // inclusive. func (dc *Context) SetRGBA(r, g, b, a float64) { … } // SetRGB sets the current color. r, g, b values should be between 0 and 1, // inclusive. Alpha will be set to 1 (fully opaque). func (dc *Context) SetRGB(r, g, b float64) { … } // MoveTo starts a new subpath within the current path starting at the // specified point. func (dc *Context) MoveTo(x, y float64) { … } // 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 (dc *Context) LineTo(x, y float64) { … } // 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 (dc *Context) QuadraticTo(x1, y1, x2, y2 float64) { … } // CubicTo adds a cubic bezier curve to the current path starting at the // current point. If there is no current point, it first performs // MoveTo(x1, y1). Because freetype/raster does not support cubic beziers, // this is emulated with many small line segments. func (dc *Context) CubicTo(x1, y1, x2, y2, x3, y3 float64) { … } // 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 (dc *Context) ClosePath() { … } // ClearPath clears the current path. There is no current point after this // operation. func (dc *Context) ClearPath() { … } // NewSubPath starts a new subpath within the current path. There is no current // point after this operation. func (dc *Context) NewSubPath() { … } func (dc *Context) capper() raster.Capper { … } func (dc *Context) joiner() raster.Joiner { … } func (dc *Context) stroke(painter raster.Painter) { … } func (dc *Context) fill(painter raster.Painter) { … } // StrokePreserve strokes the current path with the current color, line width, // line cap, line join and dash settings. The path is preserved after this // operation. func (dc *Context) StrokePreserve() { … } // 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 (dc *Context) Stroke() { … } // FillPreserve fills the current path with the current color. Open subpaths // are implicity closed. The path is preserved after this operation. func (dc *Context) FillPreserve() { … } // Fill fills the current path with the current color. Open subpaths // are implicity closed. The path is cleared after this operation. func (dc *Context) Fill() { … } // 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 (dc *Context) ClipPreserve() { … } // SetMask allows you to directly set the *image.Alpha to be used as a clipping // mask. It must be the same size as the context, else an error is returned // and the mask is unchanged. func (dc *Context) SetMask(mask *image.Alpha) error { … } // AsMask returns an *image.Alpha representing the alpha channel of this // context. This can be useful for advanced clipping operations where you first // render the mask geometry and then use it as a mask. func (dc *Context) AsMask() *image.Alpha { … } // InvertMask inverts the alpha values in the current clipping mask such that // a fully transparent region becomes fully opaque and vice versa. func (dc *Context) InvertMask() { … } // 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 (dc *Context) Clip() { … } // ResetClip clears the clipping region. func (dc *Context) ResetClip() { … } // Clear fills the entire image with the current color. func (dc *Context) Clear() { … } // SetPixel sets the color of the specified pixel using the current color. func (dc *Context) SetPixel(x, y int) { … } // DrawPoint is like DrawCircle but ensures that a circle of the specified // size is drawn regardless of the current transformation matrix. The position // is still transformed, but not the shape of the point. func (dc *Context) DrawPoint(x, y, r float64) { … } func (dc *Context) DrawLine(x1, y1, x2, y2 float64) { … } func (dc *Context) DrawRectangle(x, y, w, h float64) { … } func (dc *Context) DrawRoundedRectangle(x, y, w, h, r float64) { … } func (dc *Context) DrawEllipticalArc(x, y, rx, ry, angle1, angle2 float64) { … } func (dc *Context) DrawEllipse(x, y, rx, ry float64) { … } func (dc *Context) DrawArc(x, y, r, angle1, angle2 float64) { … } func (dc *Context) DrawCircle(x, y, r float64) { … } func (dc *Context) DrawRegularPolygon(n int, x, y, r, rotation float64) { … } // DrawImage draws the specified image at the specified point. func (dc *Context) DrawImage(im image.Image, x, y int) { … } // 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 (dc *Context) DrawImageAnchored(im image.Image, x, y int, ax, ay float64) { … } func (dc *Context) SetFontFace(fontFace font.Face) { … } func (dc *Context) LoadFontFace(fontbytes []byte, points float64) error { … } func (dc *Context) FontHeight() float64 { … } func (dc *Context) drawString(im *image.RGBA, s string, x, y float64) { … } // DrawString draws the specified text at the specified point. func (dc *Context) DrawString(s string, x, y float64) { … } // 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 (dc *Context) DrawStringAnchored(s string, x, y, ax, ay float64) { … } // DrawStringWrapped word-wraps the specified string to the given max width // and then draws it at the specified anchor point using the given line // spacing and text alignment. func (dc *Context) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align) (height float64) { … } func (dc *Context) MeasureMultilineString(s string, lineSpacing float64) (width, height float64) { … } // MeasureString returns the rendered width and height of the specified text // given the current font face. func (dc *Context) MeasureString(s string) (w, h float64) { … } // WordWrap wraps the specified string to the given max width and current // font face. func (dc *Context) WordWrap(s string, w float64) []string { … } // Identity resets the current transformation matrix to the identity matrix. // This results in no translating, scaling, rotating, or shearing. func (dc *Context) Identity() { … } // Translate updates the current matrix with a translation. func (dc *Context) Translate(x, y float64) { … } // Scale updates the current matrix with a scaling factor. // Scaling occurs about the origin. func (dc *Context) Scale(x, y float64) { … } // ScaleAbout updates the current matrix with a scaling factor. // Scaling occurs about the specified point. func (dc *Context) ScaleAbout(sx, sy, x, y float64) { … } // Rotate updates the current matrix with a clockwise rotation. // Rotation occurs about the origin. Angle is specified in radians. func (dc *Context) Rotate(angle float64) { … } // RotateAbout updates the current matrix with a clockwise rotation. // Rotation occurs about the specified point. Angle is specified in radians. func (dc *Context) RotateAbout(angle, x, y float64) { … } // Shear updates the current matrix with a shearing angle. // Shearing occurs about the origin. func (dc *Context) Shear(x, y float64) { … } // ShearAbout updates the current matrix with a shearing angle. // Shearing occurs about the specified point. func (dc *Context) ShearAbout(sx, sy, x, y float64) { … } // TransformPoint multiplies the specified point by the current matrix, // returning a transformed position. func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) { … } // InvertY flips the Y axis so that Y grows from bottom to top and Y=0 is at // the bottom of the image. func (dc *Context) InvertY() { … } // Push saves the current state of the context for later retrieval. These // can be nested. func (dc *Context) Push() { … } // Pop restores the last saved context state from the stack. func (dc *Context) Pop() { … }