Documentation ¶
Index ¶
- Constants
- Variables
- func Bresenham(img draw.Image, color color.Color, x0, y0, x1, y1 int)
- func Flatten(path *draw2d.Path, flattener Flattener, scale 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 ContextStack
- type DashVertexConverter
- type DemuxFlattener
- type Flattener
- type LineStroker
- type Liner
- type SegmentedPath
- 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 draw2d.Matrix)
- func (gc *StackGraphicContext) CubicCurveTo(cx1, cy1, cx2, cy2, x, y float64)
- func (gc *StackGraphicContext) GetFontData() draw2d.FontData
- func (gc *StackGraphicContext) GetFontSize() float64
- func (gc *StackGraphicContext) GetMatrixTransform() draw2d.Matrix
- func (gc *StackGraphicContext) IsEmpty() bool
- func (gc *StackGraphicContext) LastPoint() (float64, 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 draw2d.FillRule)
- func (gc *StackGraphicContext) SetFontData(fontData draw2d.FontData)
- func (gc *StackGraphicContext) SetFontSize(fontSize float64)
- func (gc *StackGraphicContext) SetLineCap(cap draw2d.LineCap)
- func (gc *StackGraphicContext) SetLineDash(dash []float64, dashOffset float64)
- func (gc *StackGraphicContext) SetLineJoin(join draw2d.LineJoin)
- func (gc *StackGraphicContext) SetLineWidth(lineWidth float64)
- func (gc *StackGraphicContext) SetMatrixTransform(Tr draw2d.Matrix)
- func (gc *StackGraphicContext) SetStrokeColor(c color.Color)
- func (gc *StackGraphicContext) Translate(tx, ty float64)
- type Transformer
Constants ¶
View Source
const (
// CurveRecursionLimit represents the maximum recursion that is really necessary to subsivide a curve into straight lines
CurveRecursionLimit = 32
)
Variables ¶
View Source
var DefaultFontData = draw2d.FontData{Name: "luxi", Family: draw2d.FontFamilySans, Style: draw2d.FontStyleNormal}
Functions ¶
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 ContextStack ¶
type ContextStack struct { Tr draw2d.Matrix Path *draw2d.Path LineWidth float64 Dash []float64 DashOffset float64 StrokeColor color.Color FillColor color.Color FillRule draw2d.FillRule Cap draw2d.LineCap Join draw2d.LineJoin FontSize float64 FontData draw2d.FontData Font *truetype.Font // fontSize and dpi are used to calculate scale. scale is the number of // 26.6 fixed point units in 1 em. Scale float64 Previous *ContextStack }
type DashVertexConverter ¶
type DashVertexConverter struct {
// contains filtered or unexported fields
}
func NewDashConverter ¶
func NewDashConverter(dash []float64, dashOffset float64, flattener Flattener) *DashVertexConverter
func (*DashVertexConverter) Close ¶
func (dasher *DashVertexConverter) Close()
func (*DashVertexConverter) End ¶
func (dasher *DashVertexConverter) End()
func (*DashVertexConverter) LineJoin ¶
func (dasher *DashVertexConverter) LineJoin()
func (*DashVertexConverter) LineTo ¶
func (dasher *DashVertexConverter) LineTo(x, y float64)
func (*DashVertexConverter) MoveTo ¶
func (dasher *DashVertexConverter) MoveTo(x, y float64)
type DemuxFlattener ¶
type DemuxFlattener struct {
Flatteners []Flattener
}
func (DemuxFlattener) Close ¶
func (dc DemuxFlattener) Close()
func (DemuxFlattener) End ¶
func (dc DemuxFlattener) End()
func (DemuxFlattener) LineJoin ¶
func (dc DemuxFlattener) LineJoin()
func (DemuxFlattener) LineTo ¶
func (dc DemuxFlattener) LineTo(x, y float64)
func (DemuxFlattener) MoveTo ¶
func (dc DemuxFlattener) MoveTo(x, y float64)
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 LineStroker ¶
type LineStroker struct { Flattener Flattener HalfLineWidth float64 Cap draw2d.LineCap Join draw2d.LineJoin // contains filtered or unexported fields }
func NewLineStroker ¶
func (*LineStroker) Close ¶
func (l *LineStroker) Close()
func (*LineStroker) End ¶
func (l *LineStroker) End()
func (*LineStroker) LineJoin ¶
func (l *LineStroker) LineJoin()
func (*LineStroker) LineTo ¶
func (l *LineStroker) LineTo(x, y float64)
func (*LineStroker) MoveTo ¶
func (l *LineStroker) MoveTo(x, y float64)
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 SegmentedPath ¶
type SegmentedPath struct {
Points []float64
}
func (*SegmentedPath) Close ¶
func (p *SegmentedPath) Close()
func (*SegmentedPath) End ¶
func (p *SegmentedPath) End()
func (*SegmentedPath) LineJoin ¶
func (p *SegmentedPath) LineJoin()
func (*SegmentedPath) LineTo ¶
func (p *SegmentedPath) LineTo(x, y float64)
func (*SegmentedPath) MoveTo ¶
func (p *SegmentedPath) MoveTo(x, y float64)
type StackGraphicContext ¶
type StackGraphicContext struct {
Current *ContextStack
}
func NewStackGraphicContext ¶
func NewStackGraphicContext() *StackGraphicContext
*
- Create a new Graphic context from an image
func (*StackGraphicContext) ArcTo ¶
func (gc *StackGraphicContext) ArcTo(cx, cy, rx, ry, startAngle, angle float64)
func (*StackGraphicContext) BeginPath ¶
func (gc *StackGraphicContext) BeginPath()
func (*StackGraphicContext) Close ¶
func (gc *StackGraphicContext) Close()
func (*StackGraphicContext) ComposeMatrixTransform ¶
func (gc *StackGraphicContext) ComposeMatrixTransform(Tr draw2d.Matrix)
func (*StackGraphicContext) CubicCurveTo ¶
func (gc *StackGraphicContext) CubicCurveTo(cx1, cy1, cx2, cy2, x, y float64)
func (*StackGraphicContext) GetFontData ¶
func (gc *StackGraphicContext) GetFontData() draw2d.FontData
func (*StackGraphicContext) GetFontSize ¶
func (gc *StackGraphicContext) GetFontSize() float64
func (*StackGraphicContext) GetMatrixTransform ¶
func (gc *StackGraphicContext) GetMatrixTransform() draw2d.Matrix
func (*StackGraphicContext) IsEmpty ¶
func (gc *StackGraphicContext) IsEmpty() bool
func (*StackGraphicContext) LastPoint ¶
func (gc *StackGraphicContext) LastPoint() (float64, float64)
func (*StackGraphicContext) LineTo ¶
func (gc *StackGraphicContext) LineTo(x, y float64)
func (*StackGraphicContext) MoveTo ¶
func (gc *StackGraphicContext) MoveTo(x, y float64)
func (*StackGraphicContext) QuadCurveTo ¶
func (gc *StackGraphicContext) QuadCurveTo(cx, cy, x, y float64)
func (*StackGraphicContext) Restore ¶
func (gc *StackGraphicContext) Restore()
func (*StackGraphicContext) Rotate ¶
func (gc *StackGraphicContext) Rotate(angle float64)
func (*StackGraphicContext) Save ¶
func (gc *StackGraphicContext) Save()
func (*StackGraphicContext) Scale ¶
func (gc *StackGraphicContext) Scale(sx, sy float64)
func (*StackGraphicContext) SetFillColor ¶
func (gc *StackGraphicContext) SetFillColor(c color.Color)
func (*StackGraphicContext) SetFillRule ¶
func (gc *StackGraphicContext) SetFillRule(f draw2d.FillRule)
func (*StackGraphicContext) SetFontData ¶
func (gc *StackGraphicContext) SetFontData(fontData draw2d.FontData)
func (*StackGraphicContext) SetFontSize ¶
func (gc *StackGraphicContext) SetFontSize(fontSize float64)
func (*StackGraphicContext) SetLineCap ¶
func (gc *StackGraphicContext) SetLineCap(cap draw2d.LineCap)
func (*StackGraphicContext) SetLineDash ¶
func (gc *StackGraphicContext) SetLineDash(dash []float64, dashOffset float64)
func (*StackGraphicContext) SetLineJoin ¶
func (gc *StackGraphicContext) SetLineJoin(join draw2d.LineJoin)
func (*StackGraphicContext) SetLineWidth ¶
func (gc *StackGraphicContext) SetLineWidth(lineWidth float64)
func (*StackGraphicContext) SetMatrixTransform ¶
func (gc *StackGraphicContext) SetMatrixTransform(Tr draw2d.Matrix)
func (*StackGraphicContext) SetStrokeColor ¶
func (gc *StackGraphicContext) SetStrokeColor(c color.Color)
func (*StackGraphicContext) Translate ¶
func (gc *StackGraphicContext) Translate(tx, ty float64)
type Transformer ¶
Transformer apply the Matrix transformation tr
func (Transformer) Close ¶
func (t Transformer) Close()
func (Transformer) End ¶
func (t Transformer) End()
func (Transformer) LineJoin ¶
func (t Transformer) LineJoin()
func (Transformer) LineTo ¶
func (t Transformer) LineTo(x, y float64)
func (Transformer) MoveTo ¶
func (t Transformer) MoveTo(x, y float64)
Click to show internal directories.
Click to hide internal directories.