Documentation
¶
Index ¶
- Constants
- Variables
- func Bresenham(img draw.Image, color color.Color, x0, y0, x1, y1 int)
- func ColorChannelFromFloat(v float64) uint8
- 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 GetFont(fontFamily string) *truetype.Font
- func InstallFont(fontFamily string, data []byte) error
- 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
- func (c Color) AverageWith(other Color) Color
- func (c Color) Equals(other Color) bool
- func (c Color) HSL() (h, s, l float64)
- func (c Color) IsTransparent() bool
- func (c Color) IsZero() bool
- func (c Color) RGBA() (r, g, b, a uint32)
- func (c Color) String() string
- func (c Color) StringRGB() string
- func (c Color) StringRGBA() string
- func (c Color) WithAdjustHSL(hueDelta, satDelta, lightDelta float64) Color
- func (c Color) WithAlpha(a uint8) Color
- type ContextStack
- type DashVertexConverter
- type DemuxFlattener
- type FillRule
- type Flattener
- type FontExtents
- type FtLineBuilder
- type ImageFilter
- 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(radians 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, delta 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) 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) FillRect(x1, y1, x2, y2 int)
- func (rgc *RasterGraphicContext) FillStringAt(text string, x, y float64) (cursor float64, err error)deprecated
- 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) StrokeStringAt(text string, x, y float64) (cursor float64, err error)deprecated
- type SegmentedPath
- type StackGraphicContext
- func (gc *StackGraphicContext) ArcTo(cx, cy, rx, ry, startAngle, delta 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) SetLineDash(dash []float64, dashOffset float64)
- 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 Transformer
Constants ¶
const (
// CurveRecursionLimit represents the maximum recursion that is really necessary to subsivide a curve into straight lines
CurveRecursionLimit = 32
)
Variables ¶
var ( // ColorTransparent is a fully transparent color. ColorTransparent = Color{R: 255, G: 255, B: 255, A: 0} // ColorWhite is R: 255, G: 255, B: 255. ColorWhite = Color{R: 255, G: 255, B: 255, A: 255} // ColorBlack is R: 0, G: 0, B: 0. ColorBlack = Color{R: 0, G: 0, B: 0, A: 255} // ColorGray is R: 128, G: 128, B: 128. ColorGray = Color{R: 128, G: 128, B: 128, A: 255} // ColorRed is R: 255, G: 0, B: 0. ColorRed = Color{R: 255, G: 0, B: 0, A: 255} // ColorGreen is R: 0, G: 128, B: 0. ColorGreen = Color{R: 0, G: 128, B: 0, A: 255} // ColorBlue is R: 0, G: 0, B: 255. ColorBlue = Color{R: 0, G: 0, B: 255, A: 255} // ColorSilver is R: 192, G: 192, B: 192. ColorSilver = Color{R: 192, G: 192, B: 192, A: 255} // ColorMaroon is R: 128, G: 0, B: 0. ColorMaroon = Color{R: 128, G: 0, B: 0, A: 255} // ColorPurple is R: 128, G: 0, B: 128. ColorPurple = Color{R: 128, G: 0, B: 128, A: 255} // ColorFuchsia is R: 255, G: 0, B: 255. ColorFuchsia = Color{R: 255, G: 0, B: 255, A: 255} // ColorLime is R: 0, G: 255, B: 0. ColorLime = Color{R: 0, G: 255, B: 0, A: 255} // ColorOlive is R: 128, G: 128, B: 0. ColorOlive = Color{R: 128, G: 128, B: 0, A: 255} // ColorYellow is R: 255, G: 255, B: 0. ColorYellow = Color{R: 255, G: 255, B: 0, A: 255} ColorNavy = Color{R: 0, G: 0, B: 128, A: 255} // ColorTeal is R: 0, G: 128, B: 128. ColorTeal = Color{R: 0, G: 128, B: 128, A: 255} // ColorAqua is R: 0, G: 255, B: 255. ColorAqua = Color{R: 0, G: 255, B: 255, A: 255} // ColorLightGray is R: 211, G: 211, B: 211. ColorLightGray = Color{R: 211, G: 211, B: 211, A: 255} // ColorSlateGray is R: 112, G: 128, B: 144. ColorSlateGray = Color{R: 112, G: 128, B: 144, A: 255} // ColorLightSlateGray is R: 119, G: 136, B: 211. ColorLightSlateGray = Color{R: 119, G: 136, B: 211, A: 255} // ColorAzure is R: 240, G: 255, B: 255. ColorAzure = Color{R: 240, G: 255, B: 255, A: 255} // ColorBeige is R: 245, G: 245, B: 220. ColorBeige = Color{R: 245, G: 245, B: 220, A: 255} // ColorBrown is R: 165, G: 42, B: 42. ColorBrown = Color{R: 165, G: 42, B: 42, A: 255} // ColorChocolate is R: 210, G: 105, B: 30. ColorChocolate = Color{R: 210, G: 105, B: 30, A: 255} // ColorCoral is R: 255, G: 127, B: 80. ColorCoral = Color{R: 255, G: 127, B: 80, A: 255} // ColorLightCoral is R: 240, G: 128, B: 128. ColorLightCoral = Color{R: 240, G: 128, B: 128, A: 255} // ColorGold is R: 255, G: 215, B: 0. ColorGold = Color{R: 255, G: 215, B: 0, A: 255} // ColorIndigo is R: 75, G: 0, B: 130. ColorIndigo = Color{R: 75, G: 0, B: 130, A: 255} // ColorIvory is R: 255, G: 255, B: 250. ColorIvory = Color{R: 255, G: 255, B: 250, A: 255} // ColorOrange is R: 255, G: 165, B: 0. ColorOrange = Color{R: 255, G: 165, B: 0, A: 255} // ColorPink is R: 255, G: 192, B: 203. ColorPink = Color{R: 255, G: 192, B: 203, A: 255} // ColorPlum is R: 221, G: 160, B: 221. ColorPlum = Color{R: 221, G: 160, B: 221, A: 255} // ColorSalmon is R: 250, G: 128, B: 114. ColorSalmon = Color{R: 250, G: 128, B: 114, A: 255} // ColorTan is R: 210, G: 180, B: 140. ColorTan = Color{R: 210, G: 180, B: 140, A: 255} // ColorKhaki is R: 240, G: 230, B: 140. ColorKhaki = Color{R: 240, G: 230, B: 140, A: 255} // ColorTurquoise is R: 64, G: 224, B: 208. ColorTurquoise = Color{R: 64, G: 224, B: 208, A: 255} // ColorViolet is R: 238, G: 130, B: 238. ColorViolet = Color{R: 238, G: 130, B: 238, A: 255} // ColorSkyBlue is R: 135, G: 206, B: 235. ColorSkyBlue = Color{R: 135, G: 206, B: 235, A: 255} // ColorLavender is R: 230, G: 230, B: 250. ColorLavender = Color{R: 230, G: 230, B: 250, A: 255} // ColorThistle is R: 216, G: 191, B: 216. ColorThistle = Color{R: 216, G: 191, B: 216, A: 255} )
Basic Colors from: https://www.w3.org/wiki/CSS/Properties/color/keywords
var FallbackFonts = []string{"notosans", "notosans-chartsymbols", "roboto"}
FallbackFonts is the ordered list of fallback fonts to try when a character is missing.
Functions ¶
func ColorChannelFromFloat ¶
ColorChannelFromFloat returns a normalized byte from a given float value.
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 GetFont ¶ added in v0.5.17
GetFont get the font by font family or nil if the family is not installed.
func InstallFont ¶ added in v0.5.17
InstallFont installs the font in the global registry.
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 ¶
type Color struct {
R, G, B, A uint8
}
Color is our internal color type because color.Color is bullshit.
func ColorFromAlphaMixedRGBA ¶
ColorFromAlphaMixedRGBA returns the system alpha mixed rgba values.
func ColorFromHex ¶
ColorFromHex returns a color from a css hex code.
NOTE: it will trim a leading '#' character if present.
func ColorFromKnown ¶
ColorFromKnown returns an internal color from a known (basic) color name.
func ColorFromRGBA ¶
ColorFromRGBA returns a color from a `rgb(i,i,i)` or `rgba(i,i,i,f)` css function.
func (Color) AverageWith ¶
AverageWith averages two colors.
func (Color) HSL ¶ added in v0.5.0
HSL converts outputs the color HSL (hue, saturation, lightness). H in degrees, S and L in [0,1].
func (Color) IsTransparent ¶
IsTransparent returns if the colors alpha channel is zero.
func (Color) StringRGB ¶ added in v0.4.0
StringRGB returns a CSS RGB string representation of the color.
func (Color) StringRGBA ¶ added in v0.4.0
StringRGBA returns a CSS RGBA string representation of the color.
func (Color) WithAdjustHSL ¶ added in v0.5.0
WithAdjustHSL adjusts the hue, saturation, and lightness of a color by given deltas. hueDelta is in degrees; satDelta and lightDelta are in the range [-1, 1].
type ContextStack ¶
type ContextStack struct {
Tr Matrix
Path *Path
LineWidth float64
Dash []float64
DashOffset float64
StrokeColor color.Color
FillColor color.Color
FillRule FillRule
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) End ¶
func (dasher *DashVertexConverter) End()
End forwards the completed path to the next converter (for PathBuilder interface).
func (*DashVertexConverter) LineTo ¶
func (dasher *DashVertexConverter) LineTo(x, y float64)
LineTo adds a dashed line segment to the path (for PathBuilder interface).
func (*DashVertexConverter) MoveTo ¶
func (dasher *DashVertexConverter) MoveTo(x, y float64)
MoveTo sets the starting point for the dashed path (for PathBuilder interface).
type DemuxFlattener ¶
type DemuxFlattener struct {
Flatteners []Flattener
}
DemuxFlattener is a slice of Flattener.
func (DemuxFlattener) End ¶
func (dc DemuxFlattener) End()
End signals completion to all child flatteners (for PathBuilder interface).
func (DemuxFlattener) LineTo ¶
func (dc DemuxFlattener) LineTo(x, y float64)
LineTo forwards a line command to all child flatteners (for PathBuilder interface).
func (DemuxFlattener) MoveTo ¶
func (dc DemuxFlattener) MoveTo(x, y float64)
MoveTo forwards a move command to all child flatteners (for PathBuilder 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)
// End mark the current line as finished.
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) End ¶
func (liner FtLineBuilder) End()
End finalizes the current path (for PathBuilder interface).
func (FtLineBuilder) LineTo ¶
func (liner FtLineBuilder) LineTo(x, y float64)
LineTo adds a line segment from the current point to the specified point (for PathBuilder interface).
func (FtLineBuilder) MoveTo ¶
func (liner FtLineBuilder) MoveTo(x, y float64)
MoveTo starts a new segment at the given point (for PathBuilder interface).
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 LineStroker ¶
type LineStroker struct {
Flattener Flattener
HalfLineWidth float64
// contains filtered or unexported fields
}
LineStroker draws the stroke portion of a line.
func NewLineStroker ¶
func NewLineStroker(flattener Flattener) *LineStroker
NewLineStroker creates a new line stroker.
func (*LineStroker) End ¶
func (l *LineStroker) End()
End emits the completed stroked path to the next flattener (for PathBuilder interface).
func (*LineStroker) LineTo ¶
func (l *LineStroker) LineTo(x, y float64)
LineTo adds a stroked line to the path (for PathBuilder interface).
func (*LineStroker) MoveTo ¶
func (l *LineStroker) MoveTo(x, y float64)
MoveTo records the starting point for a stroked segment (for PathBuilder 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 computes 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 translation.
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 a pure translation. A tolerance is applied when comparing matrix elements.
func (*Matrix) Transform ¶
Transform applies the transformation matrix to points. It modifies 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 modifies 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 Bézier curve to the current path.
func (*Path) QuadCurveTo ¶
QuadCurveTo adds a quadratic Bézier 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 different) 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 a 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 LineTo component in a Path. CloseComponent )
type RasterGraphicContext ¶
type RasterGraphicContext struct {
*StackGraphicContext
// contains filtered or unexported fields
}
RasterGraphicContext is the implementation of GraphicContext for a raster image.
func NewRasterGraphicContext ¶
func NewRasterGraphicContext(img *image.RGBA) *RasterGraphicContext
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) 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) FillRect ¶ added in v0.4.3
func (rgc *RasterGraphicContext) FillRect(x1, y1, x2, y2 int)
FillRect draws a filled rectangle with the provided coordinates and the current set FillColor.
func (*RasterGraphicContext) FillStringAt
deprecated
func (rgc *RasterGraphicContext) FillStringAt(text string, x, y float64) (cursor float64, err error)
Deprecated: FillStringAt is deprecated, use CreateStringPath and then Fill, or open a GitHub issue requesting it to be maintained.
func (*RasterGraphicContext) FillStroke ¶
func (rgc *RasterGraphicContext) FillStroke(paths ...*Path)
FillStroke first fills the paths and then 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) StrokeStringAt
deprecated
func (rgc *RasterGraphicContext) StrokeStringAt(text string, x, y float64) (cursor float64, err error)
Deprecated: StrokeStringAt is deprecated, it's expected that most usage is through Render.Text. It can be replaced with CreateStringPath and then Stroke, or open a GitHub issue requesting it to be maintained.
type SegmentedPath ¶
type SegmentedPath struct {
Points []float64
}
SegmentedPath is a path of disparate point sections.
func (*SegmentedPath) End ¶
func (p *SegmentedPath) End()
End completes the current path segment (for PathBuilder interface).
func (*SegmentedPath) LineTo ¶
func (p *SegmentedPath) LineTo(x, y float64)
LineTo appends a point to the current path segment (for PathBuilder interface).
func (*SegmentedPath) MoveTo ¶
func (p *SegmentedPath) MoveTo(x, y float64)
MoveTo records the first point of a new segment (for PathBuilder interface).
type StackGraphicContext ¶
type StackGraphicContext struct {
// contains filtered or unexported fields
}
StackGraphicContext is a context that does things.
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, delta 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) SetLineDash ¶
func (gc *StackGraphicContext) SetLineDash(dash []float64, dashOffset float64)
SetLineDash sets the line dash.
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 Transformer ¶
Transformer apply the Matrix transformation.
func (Transformer) End ¶
func (t Transformer) End()
End finishes the transformed path (for PathBuilder interface).
func (Transformer) LineTo ¶
func (t Transformer) LineTo(x, y float64)
LineTo transforms and forwards a line command (for PathBuilder interface).
func (Transformer) MoveTo ¶
func (t Transformer) MoveTo(x, y float64)
MoveTo transforms and passes a move command downstream (for PathBuilder interface).