Documentation ΒΆ
Index ΒΆ
- Constants
- Variables
- func Bresenham(img draw.Image, color color.Color, x0, y0, x1, y1 int)
- func DrawContour(path PathBuilder, ps []truetype.Point, dx, dy float64)
- func DrawImage(src image.Image, dest draw.Image, tr Matrix, op draw.Op, filter ImageFilter)
- func Flatten(path *Path, flattener Flattener, scale float64)
- func PixelsToPoints(dpi, pixels float64) (points float64)
- func PointsToPixels(dpi, points float64) (pixels float64)
- func PolylineBresenham(img draw.Image, c color.Color, s ...float64)
- func SubdivideCubic(c, c1, c2 []float64)
- func SubdivideQuad(c, c1, c2 []float64)
- func TraceArc(t Liner, x, y, rx, ry, start, angle, scale float64) (lastX, lastY float64)
- func TraceCubic(t Liner, cubic []float64, flatteningThreshold float64)
- func TraceQuad(t Liner, quad []float64, flatteningThreshold float64)
- type Color
- type ContextStack
- type DashVertexConverter
- type DemuxFlattener
- type FillRule
- type Flattener
- type FontExtents
- type FtLineBuilder
- type GraphicContext
- type Halign
- type ImageFilter
- type ImageScaling
- type LineCap
- type LineJoin
- type LineStroker
- type Liner
- type Matrix
- func (tr *Matrix) Compose(trToCompose Matrix)
- func (tr Matrix) Copy() Matrix
- func (tr Matrix) Determinant() float64
- func (tr Matrix) Equals(tr2 Matrix) bool
- func (tr Matrix) GetScale() float64
- func (tr Matrix) GetScaling() (x, y float64)
- func (tr Matrix) GetTranslation() (x, y float64)
- func (tr *Matrix) Inverse()
- func (tr Matrix) InverseTransform(points []float64)
- func (tr Matrix) InverseTransformPoint(x, y float64) (xres, yres float64)
- func (tr Matrix) IsIdentity() bool
- func (tr Matrix) IsTranslation() bool
- func (tr *Matrix) Rotate(angle float64)
- func (tr *Matrix) Scale(sx, sy float64)
- func (tr Matrix) Transform(points []float64)
- func (tr Matrix) TransformPoint(x, y float64) (xres, yres float64)
- func (tr Matrix) TransformRectangle(x0, y0, x2, y2 float64) (nx0, ny0, nx2, ny2 float64)
- func (tr *Matrix) Translate(tx, ty float64)
- func (tr Matrix) VectorTransform(points []float64)
- type Painter
- type Path
- func (p *Path) ArcTo(cx, cy, rx, ry, startAngle, angle float64)
- func (p *Path) Clear()
- func (p *Path) Close()
- func (p *Path) Copy() (dest *Path)
- func (p *Path) CubicCurveTo(cx1, cy1, cx2, cy2, x, y float64)
- func (p *Path) IsEmpty() bool
- func (p *Path) LastPoint() (x, y float64)
- func (p *Path) LineTo(x, y float64)
- func (p *Path) MoveTo(x, y float64)
- func (p *Path) QuadCurveTo(cx, cy, x, y float64)
- func (p *Path) String() string
- type PathBuilder
- type PathComponent
- type RasterGraphicContext
- func (rgc *RasterGraphicContext) Clear()
- func (rgc *RasterGraphicContext) ClearRect(x1, y1, x2, y2 int)
- func (rgc *RasterGraphicContext) CreateStringPath(s string, x, y float64) (cursor float64, err error)
- func (rgc *RasterGraphicContext) DrawImage(img image.Image)
- func (rgc *RasterGraphicContext) Fill(paths ...*Path)
- func (rgc *RasterGraphicContext) FillString(text string) (cursor float64, err error)
- func (rgc *RasterGraphicContext) FillStringAt(text string, x, y float64) (cursor float64, err error)
- func (rgc *RasterGraphicContext) FillStroke(paths ...*Path)
- func (rgc *RasterGraphicContext) GetDPI() float64
- func (rgc *RasterGraphicContext) GetFont() *truetype.Font
- func (rgc *RasterGraphicContext) GetStringBounds(s string) (left, top, right, bottom float64, err error)
- func (rgc *RasterGraphicContext) SetDPI(dpi float64)
- func (rgc *RasterGraphicContext) SetFont(font *truetype.Font)
- func (rgc *RasterGraphicContext) SetFontSize(fontSizePoints float64)
- func (rgc *RasterGraphicContext) Stroke(paths ...*Path)
- func (rgc *RasterGraphicContext) StrokeString(text string) (cursor float64, err error)
- func (rgc *RasterGraphicContext) StrokeStringAt(text string, x, y float64) (cursor float64, err error)
- type ScalingPolicy
- type SegmentedPath
- type SolidFillStyle
- type StackGraphicContext
- func (gc *StackGraphicContext) ArcTo(cx, cy, rx, ry, startAngle, angle float64)
- func (gc *StackGraphicContext) BeginPath()
- func (gc *StackGraphicContext) Close()
- func (gc *StackGraphicContext) ComposeMatrixTransform(tr Matrix)
- func (gc *StackGraphicContext) CubicCurveTo(cx1, cy1, cx2, cy2, x, y float64)
- func (gc *StackGraphicContext) GetFont() *truetype.Font
- func (gc *StackGraphicContext) GetFontSize() float64
- func (gc *StackGraphicContext) GetMatrixTransform() Matrix
- func (gc *StackGraphicContext) IsEmpty() bool
- func (gc *StackGraphicContext) LastPoint() (x float64, y float64)
- func (gc *StackGraphicContext) LineTo(x, y float64)
- func (gc *StackGraphicContext) MoveTo(x, y float64)
- func (gc *StackGraphicContext) QuadCurveTo(cx, cy, x, y float64)
- func (gc *StackGraphicContext) Restore()
- func (gc *StackGraphicContext) Rotate(angle float64)
- func (gc *StackGraphicContext) Save()
- func (gc *StackGraphicContext) Scale(sx, sy float64)
- func (gc *StackGraphicContext) SetFillColor(c color.Color)
- func (gc *StackGraphicContext) SetFillRule(f FillRule)
- func (gc *StackGraphicContext) SetFont(f *truetype.Font)
- func (gc *StackGraphicContext) SetFontSize(fontSizePoints float64)
- func (gc *StackGraphicContext) SetLineCap(cap LineCap)
- func (gc *StackGraphicContext) SetLineDash(dash []float64, dashOffset float64)
- func (gc *StackGraphicContext) SetLineJoin(join LineJoin)
- func (gc *StackGraphicContext) SetLineWidth(lineWidth float64)
- func (gc *StackGraphicContext) SetMatrixTransform(tr Matrix)
- func (gc *StackGraphicContext) SetStrokeColor(c color.Color)
- func (gc *StackGraphicContext) Translate(tx, ty float64)
- type StrokeStyle
- type TextStyle
- type Transformer
- type Valign
Constants ΒΆ
const ( // HalignLeft Horizontally align to left HalignLeft = iota // HalignCenter Horizontally align to center HalignCenter // HalignRight Horizontally align to right HalignRight )
const (
// CurveRecursionLimit represents the maximum recursion that is really necessary to subsivide a curve into straight lines
CurveRecursionLimit = 32
)
const (
// DefaultDPI is the default image DPI.
DefaultDPI = 96.0
)
Variables ΒΆ
var ( // ColorTransparent is a fully transparent color. ColorTransparent = Color{} // ColorWhite is white. ColorWhite = Color{R: 255, G: 255, B: 255, A: 255} // ColorBlack is black. ColorBlack = Color{R: 0, G: 0, B: 0, A: 255} // ColorRed is red. ColorRed = Color{R: 255, G: 0, B: 0, A: 255} // ColorGreen is green. ColorGreen = Color{R: 0, G: 255, B: 0, A: 255} // ColorBlue is blue. ColorBlue = Color{R: 0, G: 0, B: 255, A: 255} )
Functions ΒΆ
func DrawContour ΒΆ
func DrawContour(path PathBuilder, ps []truetype.Point, dx, dy float64)
DrawContour draws the given closed contour at the given sub-pixel offset.
func DrawImage ΒΆ
DrawImage draws an image into dest using an affine transformation matrix, an op and a filter
func PixelsToPoints ΒΆ
PixelsToPoints returns the points for a given number of pixels at a DPI.
func PointsToPixels ΒΆ
PointsToPixels returns the pixels for a given number of points at a DPI.
func PolylineBresenham ΒΆ
PolylineBresenham draws a polyline to an image
func SubdivideCubic ΒΆ
func SubdivideCubic(c, c1, c2 []float64)
SubdivideCubic a Bezier cubic curve in 2 equivalents Bezier cubic curves. c1 and c2 parameters are the resulting curves
func SubdivideQuad ΒΆ
func SubdivideQuad(c, c1, c2 []float64)
SubdivideQuad a Bezier quad curve in 2 equivalents Bezier quad curves. c1 and c2 parameters are the resulting curves
func TraceCubic ΒΆ
TraceCubic generate lines subdividing the cubic curve using a Liner flattening_threshold helps determines the flattening expectation of the curve
Types ΒΆ
type Color ΒΆ
Color is our internal color type because color.Color is bullshit.
func ColorFromHex ΒΆ
ColorFromHex returns a color from a css hex code.
func (Color) IsTransparent ΒΆ
IsTransparent returns if the colors alpha channel is zero.
type ContextStack ΒΆ
type ContextStack struct { Tr Matrix Path *Path LineWidth float64 Dash []float64 DashOffset float64 StrokeColor color.Color FillColor color.Color FillRule FillRule Cap LineCap Join LineJoin FontSizePoints float64 Font *truetype.Font Scale float64 Previous *ContextStack }
ContextStack is a graphic context implementation.
type DashVertexConverter ΒΆ
type DashVertexConverter struct {
// contains filtered or unexported fields
}
DashVertexConverter is a converter for dash vertexes.
func NewDashVertexConverter ΒΆ
func NewDashVertexConverter(dash []float64, dashOffset float64, flattener Flattener) *DashVertexConverter
NewDashVertexConverter creates a new dash converter.
func (*DashVertexConverter) Close ΒΆ
func (dasher *DashVertexConverter) Close()
Close implements the pathbuilder interface.
func (*DashVertexConverter) End ΒΆ
func (dasher *DashVertexConverter) End()
End implements the pathbuilder interface.
func (*DashVertexConverter) LineJoin ΒΆ
func (dasher *DashVertexConverter) LineJoin()
LineJoin implements the pathbuilder interface.
func (*DashVertexConverter) LineTo ΒΆ
func (dasher *DashVertexConverter) LineTo(x, y float64)
LineTo implements the pathbuilder interface.
func (*DashVertexConverter) MoveTo ΒΆ
func (dasher *DashVertexConverter) MoveTo(x, y float64)
MoveTo implements the pathbuilder interface.
type DemuxFlattener ΒΆ
type DemuxFlattener struct {
Flatteners []Flattener
}
DemuxFlattener is a flattener
func (DemuxFlattener) Close ΒΆ
func (dc DemuxFlattener) Close()
Close implements the path builder interface.
func (DemuxFlattener) End ΒΆ
func (dc DemuxFlattener) End()
End implements the path builder interface.
func (DemuxFlattener) LineJoin ΒΆ
func (dc DemuxFlattener) LineJoin()
LineJoin implements the path builder interface.
func (DemuxFlattener) LineTo ΒΆ
func (dc DemuxFlattener) LineTo(x, y float64)
LineTo implements the path builder interface.
func (DemuxFlattener) MoveTo ΒΆ
func (dc DemuxFlattener) MoveTo(x, y float64)
MoveTo implements the path builder interface.
type FillRule ΒΆ
type FillRule int
FillRule defines the type for fill rules
const ( // FillRuleEvenOdd determines the "insideness" of a point in the shape // by drawing a ray from that point to infinity in any direction // and counting the number of path segments from the given shape that the ray crosses. // If this number is odd, the point is inside; if even, the point is outside. FillRuleEvenOdd FillRule = iota // FillRuleWinding determines the "insideness" of a point in the shape // by drawing a ray from that point to infinity in any direction // and then examining the places where a segment of the shape crosses the ray. // Starting with a count of zero, add one each time a path segment crosses // the ray from left to right and subtract one each time // a path segment crosses the ray from right to left. After counting the crossings, // if the result is zero then the point is outside the path. Otherwise, it is inside. FillRuleWinding )
type Flattener ΒΆ
type Flattener interface { // MoveTo Start a New line from the point (x, y) MoveTo(x, y float64) // LineTo Draw a line from the current position to the point (x, y) LineTo(x, y float64) // LineJoin add the most recent starting point to close the path to create a polygon LineJoin() // Close add the most recent starting point to close the path to create a polygon Close() // End mark the current line as finished so we can draw caps End() }
Flattener receive segment definition
type FontExtents ΒΆ
type FontExtents struct { // Ascent is the distance that the text // extends above the baseline. Ascent float64 // Descent is the distance that the text // extends below the baseline. The descent // is given as a negative value. Descent float64 // Height is the distance from the lowest // descending point to the highest ascending // point. Height float64 }
FontExtents contains font metric information.
func Extents ΒΆ
func Extents(font *truetype.Font, size float64) FontExtents
Extents returns the FontExtents for a font. TODO needs to read this https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/Chap2.html#intro
type FtLineBuilder ΒΆ
FtLineBuilder is a builder for freetype raster glyphs.
func (FtLineBuilder) Close ΒΆ
func (liner FtLineBuilder) Close()
Close implements the path builder interface.
func (FtLineBuilder) End ΒΆ
func (liner FtLineBuilder) End()
End implements the path builder interface.
func (FtLineBuilder) LineJoin ΒΆ
func (liner FtLineBuilder) LineJoin()
LineJoin implements the path builder interface.
func (FtLineBuilder) LineTo ΒΆ
func (liner FtLineBuilder) LineTo(x, y float64)
LineTo implements the path builder interface.
func (FtLineBuilder) MoveTo ΒΆ
func (liner FtLineBuilder) MoveTo(x, y float64)
MoveTo implements the path builder interface.
type GraphicContext ΒΆ
type GraphicContext interface { // PathBuilder describes the interface for path drawing PathBuilder // BeginPath creates a new path BeginPath() // GetMatrixTransform returns the current transformation matrix GetMatrixTransform() Matrix // SetMatrixTransform sets the current transformation matrix SetMatrixTransform(tr Matrix) // ComposeMatrixTransform composes the current transformation matrix with tr ComposeMatrixTransform(tr Matrix) // Rotate applies a rotation to the current transformation matrix. angle is in radian. Rotate(angle float64) // Translate applies a translation to the current transformation matrix. Translate(tx, ty float64) // Scale applies a scale to the current transformation matrix. Scale(sx, sy float64) // SetStrokeColor sets the current stroke color SetStrokeColor(c color.Color) // SetFillColor sets the current fill color SetFillColor(c color.Color) // SetFillRule sets the current fill rule SetFillRule(f FillRule) // SetLineWidth sets the current line width SetLineWidth(lineWidth float64) // SetLineCap sets the current line cap SetLineCap(cap LineCap) // SetLineJoin sets the current line join SetLineJoin(join LineJoin) // SetLineDash sets the current dash SetLineDash(dash []float64, dashOffset float64) // SetFontSize sets the current font size SetFontSize(fontSize float64) // GetFontSize gets the current font size GetFontSize() float64 // SetFont sets the font for the context SetFont(f *truetype.Font) // GetFont returns the current font GetFont() *truetype.Font // DrawImage draws the raster image in the current canvas DrawImage(image image.Image) // Save the context and push it to the context stack Save() // Restore remove the current context and restore the last one Restore() // Clear fills the current canvas with a default transparent color Clear() // ClearRect fills the specified rectangle with a default transparent color ClearRect(x1, y1, x2, y2 int) // SetDPI sets the current DPI SetDPI(dpi int) // GetDPI gets the current DPI GetDPI() int // GetStringBounds gets pixel bounds(dimensions) of given string GetStringBounds(s string) (left, top, right, bottom float64) // CreateStringPath creates a path from the string s at x, y CreateStringPath(text string, x, y float64) (cursor float64) // FillString draws the text at point (0, 0) FillString(text string) (cursor float64) // FillStringAt draws the text at the specified point (x, y) FillStringAt(text string, x, y float64) (cursor float64) // StrokeString draws the contour of the text at point (0, 0) StrokeString(text string) (cursor float64) // StrokeStringAt draws the contour of the text at point (x, y) StrokeStringAt(text string, x, y float64) (cursor float64) // Stroke strokes the paths with the color specified by SetStrokeColor Stroke(paths ...*Path) // Fill fills the paths with the color specified by SetFillColor Fill(paths ...*Path) // FillStroke first fills the paths and than strokes them FillStroke(paths ...*Path) }
GraphicContext describes the interface for the various backends (images, pdf, opengl, ...)
type ImageFilter ΒΆ
type ImageFilter int
ImageFilter defines the type of filter to use
const ( // LinearFilter defines a linear filter LinearFilter ImageFilter = iota // BilinearFilter defines a bilinear filter BilinearFilter // BicubicFilter defines a bicubic filter BicubicFilter )
type ImageScaling ΒΆ
type ImageScaling struct { // Horizontal Alignment of the image Halign Halign // Vertical Alignment of the image Valign Valign // Width Height used by scaling policy Width, Height float64 // ScalingPolicy defines the scaling policy to applied to the image ScalingPolicy ScalingPolicy }
ImageScaling style attributes used to display the image
type LineStroker ΒΆ
type LineStroker struct { Flattener Flattener HalfLineWidth float64 Cap LineCap Join LineJoin // contains filtered or unexported fields }
LineStroker draws the stroke portion of a line.
func NewLineStroker ΒΆ
func NewLineStroker(c LineCap, j LineJoin, flattener Flattener) *LineStroker
NewLineStroker creates a new line stroker.
func (*LineStroker) Close ΒΆ
func (l *LineStroker) Close()
Close implements the path builder interface.
func (*LineStroker) LineJoin ΒΆ
func (l *LineStroker) LineJoin()
LineJoin implements the path builder interface.
func (*LineStroker) LineTo ΒΆ
func (l *LineStroker) LineTo(x, y float64)
LineTo implements the path builder interface.
func (*LineStroker) MoveTo ΒΆ
func (l *LineStroker) MoveTo(x, y float64)
MoveTo implements the path builder interface.
type Liner ΒΆ
type Liner interface { // LineTo Draw a line from the current position to the point (x, y) LineTo(x, y float64) }
Liner receive segment definition
type Matrix ΒΆ
type Matrix [6]float64
Matrix represents an affine transformation
func NewIdentityMatrix ΒΆ
func NewIdentityMatrix() Matrix
NewIdentityMatrix creates an identity transformation matrix.
func NewMatrixFromRects ΒΆ
NewMatrixFromRects creates a transformation matrix, combining a scale and a translation, that transform rectangle1 into rectangle2.
func NewRotationMatrix ΒΆ
NewRotationMatrix creates a rotation transformation matrix. angle is in radian
func NewScaleMatrix ΒΆ
NewScaleMatrix creates a transformation matrix with a sx, sy scale factor
func NewTranslationMatrix ΒΆ
NewTranslationMatrix creates a transformation matrix with a translation tx and ty translation parameter
func (Matrix) Determinant ΒΆ
Determinant compute the determinant of the matrix
func (Matrix) Equals ΒΆ
Equals tests if a two transformation are equal. A tolerance is applied when comparing matrix elements.
func (Matrix) GetScaling ΒΆ
GetScaling gets the matrix scaling.
func (Matrix) GetTranslation ΒΆ
GetTranslation gets the matrix traslation.
func (Matrix) InverseTransform ΒΆ
InverseTransform applies the transformation inverse matrix to the rectangle represented by the min and the max point of the rectangle
func (Matrix) InverseTransformPoint ΒΆ
InverseTransformPoint applies the transformation inverse matrix to point. It returns the point the transformed point.
func (Matrix) IsIdentity ΒΆ
IsIdentity tests if a transformation is the identity transformation. A tolerance is applied when comparing matrix elements.
func (Matrix) IsTranslation ΒΆ
IsTranslation tests if a transformation is is a pure translation. A tolerance is applied when comparing matrix elements.
func (Matrix) Transform ΒΆ
Transform applies the transformation matrix to points. It modify the points passed in parameter.
func (Matrix) TransformPoint ΒΆ
TransformPoint applies the transformation matrix to point. It returns the point the transformed point.
func (Matrix) TransformRectangle ΒΆ
TransformRectangle applies the transformation matrix to the rectangle represented by the min and the max point of the rectangle
func (Matrix) VectorTransform ΒΆ
VectorTransform applies the transformation matrix to points without using the translation parameter of the affine matrix. It modify the points passed in parameter.
type Painter ΒΆ
Painter implements the freetype raster.Painter and has a SetColor method like the RGBAPainter
type Path ΒΆ
type Path struct { // Components is a slice of PathComponent in a Path and mark the role of each points in the Path Components []PathComponent // Points are combined with Components to have a specific role in the path Points []float64 // contains filtered or unexported fields }
Path stores points
func (*Path) CubicCurveTo ΒΆ
CubicCurveTo adds a cubic bezier curve to the current path
func (*Path) QuadCurveTo ΒΆ
QuadCurveTo adds a quadratic bezier curve to the current path
type PathBuilder ΒΆ
type PathBuilder interface { // LastPoint returns the current point of the current sub path LastPoint() (x, y float64) // MoveTo creates a new subpath that start at the specified point MoveTo(x, y float64) // LineTo adds a line to the current subpath LineTo(x, y float64) // QuadCurveTo adds a quadratic BΓ©zier curve to the current subpath QuadCurveTo(cx, cy, x, y float64) // CubicCurveTo adds a cubic BΓ©zier curve to the current subpath CubicCurveTo(cx1, cy1, cx2, cy2, x, y float64) // ArcTo adds an arc to the current subpath ArcTo(cx, cy, rx, ry, startAngle, angle float64) // Close creates a line from the current point to the last MoveTo // point (if not the same) and mark the path as closed so the // first and last lines join nicely. Close() }
PathBuilder describes the interface for path drawing.
type PathComponent ΒΆ
type PathComponent int
PathComponent represents component of a path
const ( // MoveToComponent is a MoveTo component in a Path MoveToComponent PathComponent = iota // LineToComponent is a LineTo component in a Path LineToComponent // QuadCurveToComponent is a QuadCurveTo component in a Path QuadCurveToComponent // CubicCurveToComponent is a CubicCurveTo component in a Path CubicCurveToComponent // ArcToComponent is a ArcTo component in a Path ArcToComponent // CloseComponent is a ArcTo component in a Path CloseComponent )
type RasterGraphicContext ΒΆ
type RasterGraphicContext struct { *StackGraphicContext DPI float64 // contains filtered or unexported fields }
RasterGraphicContext is the implementation of GraphicContext for a raster image
func NewRasterGraphicContext ΒΆ
func NewRasterGraphicContext(img draw.Image) (*RasterGraphicContext, error)
NewRasterGraphicContext creates a new Graphic context from an image.
func NewRasterGraphicContextWithPainter ΒΆ
func NewRasterGraphicContextWithPainter(img draw.Image, painter Painter) *RasterGraphicContext
NewRasterGraphicContextWithPainter creates a new Graphic context from an image and a Painter (see Freetype-go)
func (*RasterGraphicContext) Clear ΒΆ
func (rgc *RasterGraphicContext) Clear()
Clear fills the current canvas with a default transparent color
func (*RasterGraphicContext) ClearRect ΒΆ
func (rgc *RasterGraphicContext) ClearRect(x1, y1, x2, y2 int)
ClearRect fills the current canvas with a default transparent color at the specified rectangle
func (*RasterGraphicContext) CreateStringPath ΒΆ
func (rgc *RasterGraphicContext) CreateStringPath(s string, x, y float64) (cursor float64, err error)
CreateStringPath creates a path from the string s at x, y, and returns the string width. The text is placed so that the left edge of the em square of the first character of s and the baseline intersect at x, y. The majority of the affected pixels will be above and to the right of the point, but some may be below or to the left. For example, drawing a string that starts with a 'J' in an italic font may affect pixels below and left of the point.
func (*RasterGraphicContext) DrawImage ΒΆ
func (rgc *RasterGraphicContext) DrawImage(img image.Image)
DrawImage draws the raster image in the current canvas
func (*RasterGraphicContext) Fill ΒΆ
func (rgc *RasterGraphicContext) Fill(paths ...*Path)
Fill fills the paths with the color specified by SetFillColor
func (*RasterGraphicContext) FillString ΒΆ
func (rgc *RasterGraphicContext) FillString(text string) (cursor float64, err error)
FillString draws the text at point (0, 0)
func (*RasterGraphicContext) FillStringAt ΒΆ
func (rgc *RasterGraphicContext) FillStringAt(text string, x, y float64) (cursor float64, err error)
FillStringAt draws the text at the specified point (x, y)
func (*RasterGraphicContext) FillStroke ΒΆ
func (rgc *RasterGraphicContext) FillStroke(paths ...*Path)
FillStroke first fills the paths and than strokes them
func (*RasterGraphicContext) GetDPI ΒΆ
func (rgc *RasterGraphicContext) GetDPI() float64
GetDPI returns the resolution of the Image GraphicContext
func (*RasterGraphicContext) GetFont ΒΆ
func (rgc *RasterGraphicContext) GetFont() *truetype.Font
GetFont returns the font used to draw text.
func (*RasterGraphicContext) GetStringBounds ΒΆ
func (rgc *RasterGraphicContext) GetStringBounds(s string) (left, top, right, bottom float64, err error)
GetStringBounds returns the approximate pixel bounds of a string.
func (*RasterGraphicContext) SetDPI ΒΆ
func (rgc *RasterGraphicContext) SetDPI(dpi float64)
SetDPI sets the screen resolution in dots per inch.
func (*RasterGraphicContext) SetFont ΒΆ
func (rgc *RasterGraphicContext) SetFont(font *truetype.Font)
SetFont sets the font used to draw text.
func (*RasterGraphicContext) SetFontSize ΒΆ
func (rgc *RasterGraphicContext) SetFontSize(fontSizePoints float64)
SetFontSize sets the font size in points (as in βa 12 point fontβ).
func (*RasterGraphicContext) Stroke ΒΆ
func (rgc *RasterGraphicContext) Stroke(paths ...*Path)
Stroke strokes the paths with the color specified by SetStrokeColor
func (*RasterGraphicContext) StrokeString ΒΆ
func (rgc *RasterGraphicContext) StrokeString(text string) (cursor float64, err error)
StrokeString draws the contour of the text at point (0, 0)
func (*RasterGraphicContext) StrokeStringAt ΒΆ
func (rgc *RasterGraphicContext) StrokeStringAt(text string, x, y float64) (cursor float64, err error)
StrokeStringAt draws the contour of the text at point (x, y)
type ScalingPolicy ΒΆ
type ScalingPolicy int
ScalingPolicy is a constant to define how to scale an image
const ( // ScalingNone no scaling applied ScalingNone ScalingPolicy = iota // ScalingStretch the image is stretched so that its width and height are exactly the given width and height ScalingStretch // ScalingWidth the image is scaled so that its width is exactly the given width ScalingWidth // ScalingHeight the image is scaled so that its height is exactly the given height ScalingHeight // ScalingFit the image is scaled to the largest scale that allow the image to fit within a rectangle width x height ScalingFit // ScalingSameArea the image is scaled so that its area is exactly the area of the given rectangle width x height ScalingSameArea // ScalingFill the image is scaled to the smallest scale that allow the image to fully cover a rectangle width x height ScalingFill )
type SegmentedPath ΒΆ
type SegmentedPath struct {
Points []float64
}
SegmentedPath is a path of disparate point sectinos.
func (*SegmentedPath) LineJoin ΒΆ
func (p *SegmentedPath) LineJoin()
LineJoin implements the path interface.
func (*SegmentedPath) LineTo ΒΆ
func (p *SegmentedPath) LineTo(x, y float64)
LineTo implements the path interface.
func (*SegmentedPath) MoveTo ΒΆ
func (p *SegmentedPath) MoveTo(x, y float64)
MoveTo implements the path interface.
type SolidFillStyle ΒΆ
type SolidFillStyle struct { // Color defines the line color Color color.Color // FillRule defines the file rule to used FillRule FillRule }
SolidFillStyle define style attributes for a solid fill style
type StackGraphicContext ΒΆ
type StackGraphicContext struct {
// contains filtered or unexported fields
}
StackGraphicContext is a context that does thngs.
func NewStackGraphicContext ΒΆ
func NewStackGraphicContext() *StackGraphicContext
NewStackGraphicContext Create a new Graphic context from an image
func (*StackGraphicContext) ArcTo ΒΆ
func (gc *StackGraphicContext) ArcTo(cx, cy, rx, ry, startAngle, angle float64)
ArcTo draws an arc.
func (*StackGraphicContext) BeginPath ΒΆ
func (gc *StackGraphicContext) BeginPath()
BeginPath starts a new path.
func (*StackGraphicContext) ComposeMatrixTransform ΒΆ
func (gc *StackGraphicContext) ComposeMatrixTransform(tr Matrix)
ComposeMatrixTransform composes a transform into the current transform.
func (*StackGraphicContext) CubicCurveTo ΒΆ
func (gc *StackGraphicContext) CubicCurveTo(cx1, cy1, cx2, cy2, x, y float64)
CubicCurveTo draws a cubic curve.
func (*StackGraphicContext) GetFont ΒΆ
func (gc *StackGraphicContext) GetFont() *truetype.Font
GetFont returns the font.
func (*StackGraphicContext) GetFontSize ΒΆ
func (gc *StackGraphicContext) GetFontSize() float64
GetFontSize gets the font size.
func (*StackGraphicContext) GetMatrixTransform ΒΆ
func (gc *StackGraphicContext) GetMatrixTransform() Matrix
GetMatrixTransform returns the matrix transform.
func (*StackGraphicContext) IsEmpty ΒΆ
func (gc *StackGraphicContext) IsEmpty() bool
IsEmpty returns if the path is empty.
func (*StackGraphicContext) LastPoint ΒΆ
func (gc *StackGraphicContext) LastPoint() (x float64, y float64)
LastPoint returns the last point on the path.
func (*StackGraphicContext) LineTo ΒΆ
func (gc *StackGraphicContext) LineTo(x, y float64)
LineTo draws a line.
func (*StackGraphicContext) MoveTo ΒΆ
func (gc *StackGraphicContext) MoveTo(x, y float64)
MoveTo moves the cursor for a path.
func (*StackGraphicContext) QuadCurveTo ΒΆ
func (gc *StackGraphicContext) QuadCurveTo(cx, cy, x, y float64)
QuadCurveTo draws a quad curve.
func (*StackGraphicContext) Restore ΒΆ
func (gc *StackGraphicContext) Restore()
Restore restores the previous context.
func (*StackGraphicContext) Rotate ΒΆ
func (gc *StackGraphicContext) Rotate(angle float64)
Rotate rotates the matrix transform by an angle in degrees.
func (*StackGraphicContext) Save ΒΆ
func (gc *StackGraphicContext) Save()
Save pushes a context onto the stack.
func (*StackGraphicContext) Scale ΒΆ
func (gc *StackGraphicContext) Scale(sx, sy float64)
Scale scales a transform.
func (*StackGraphicContext) SetFillColor ΒΆ
func (gc *StackGraphicContext) SetFillColor(c color.Color)
SetFillColor sets the fill color.
func (*StackGraphicContext) SetFillRule ΒΆ
func (gc *StackGraphicContext) SetFillRule(f FillRule)
SetFillRule sets the fill rule.
func (*StackGraphicContext) SetFont ΒΆ
func (gc *StackGraphicContext) SetFont(f *truetype.Font)
SetFont sets the current font.
func (*StackGraphicContext) SetFontSize ΒΆ
func (gc *StackGraphicContext) SetFontSize(fontSizePoints float64)
SetFontSize sets the font size.
func (*StackGraphicContext) SetLineCap ΒΆ
func (gc *StackGraphicContext) SetLineCap(cap LineCap)
SetLineCap sets the line cap.
func (*StackGraphicContext) SetLineDash ΒΆ
func (gc *StackGraphicContext) SetLineDash(dash []float64, dashOffset float64)
SetLineDash sets the line dash.
func (*StackGraphicContext) SetLineJoin ΒΆ
func (gc *StackGraphicContext) SetLineJoin(join LineJoin)
SetLineJoin sets the line join.
func (*StackGraphicContext) SetLineWidth ΒΆ
func (gc *StackGraphicContext) SetLineWidth(lineWidth float64)
SetLineWidth sets the line width.
func (*StackGraphicContext) SetMatrixTransform ΒΆ
func (gc *StackGraphicContext) SetMatrixTransform(tr Matrix)
SetMatrixTransform sets the matrix transform.
func (*StackGraphicContext) SetStrokeColor ΒΆ
func (gc *StackGraphicContext) SetStrokeColor(c color.Color)
SetStrokeColor sets the stroke color.
func (*StackGraphicContext) Translate ΒΆ
func (gc *StackGraphicContext) Translate(tx, ty float64)
Translate translates a transform.
type StrokeStyle ΒΆ
type StrokeStyle struct { // Color defines the color of stroke Color color.Color // Line width Width float64 // Line cap style rounded, butt or square LineCap LineCap // Line join style bevel, round or miter LineJoin LineJoin // offset of the first dash DashOffset float64 // array represented dash length pair values are plain dash and impair are space between dash // if empty display plain line Dash []float64 }
StrokeStyle keeps stroke style attributes that is used by the Stroke method of a Drawer
type TextStyle ΒΆ
type TextStyle struct { // Color defines the color of text Color color.Color // Size font size Size float64 // The font to use Font *truetype.Font // Horizontal Alignment of the text Halign Halign // Vertical Alignment of the text Valign Valign }
TextStyle describe text property
type Transformer ΒΆ
Transformer apply the Matrix transformation tr
func (Transformer) Close ΒΆ
func (t Transformer) Close()
Close implements the path builder interface.
func (Transformer) LineJoin ΒΆ
func (t Transformer) LineJoin()
LineJoin implements the path builder interface.
func (Transformer) LineTo ΒΆ
func (t Transformer) LineTo(x, y float64)
LineTo implements the path builder interface.
func (Transformer) MoveTo ΒΆ
func (t Transformer) MoveTo(x, y float64)
MoveTo implements the path builder interface.