draw2dbase

package
v0.0.0-...-34cdf21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2015 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

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 Flatten

func Flatten(path *draw2d.Path, flattener Flattener, scale float64)

Flatten convert curves into straight segments keeping join segments info

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 TraceArc

func TraceArc(t Liner, x, y, rx, ry, start, angle, scale float64) (lastX, lastY float64)

TraceArc trace an arc using a Liner

func TraceCubic

func TraceCubic(t Liner, cubic []float64, flatteningThreshold float64)

TraceCubic generate lines subdividing the cubic curve using a Liner flattening_threshold helps determines the flattening expectation of the curve

func TraceQuad

func TraceQuad(t Liner, quad []float64, flatteningThreshold float64)

TraceQuad generate lines subdividing the 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 NewLineStroker(c draw2d.LineCap, j draw2d.LineJoin, flattener Flattener) *LineStroker

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

type Transformer struct {
	Tr        draw2d.Matrix
	Flattener Flattener
}

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL