Documentation ¶
Overview ¶
The stroke package provides functions for stroking cubic bezier paths.
Unlike many path-stroking implementations, which "flatten" cubic curves to sequences of quadratic curves, or even of straight line segments, it works with cubic curves all the way through. This results in significantly fewer segments in the output.
Many of the algorithms come from https://pomax.github.io/bezierinfo/
Index ¶
- Constants
- func Dash(path [][]Segment, pattern []float32, phase float32) [][]Segment
- func Stroke(path [][]Segment, opt Options) [][]Segment
- type CapStyle
- type JoinStyle
- type Options
- type Point
- type Segment
- func AppendArc(dst []Segment, start, center Point, angle float32) []Segment
- func AppendEllipticalArc(dst []Segment, start, f1, f2 Point, angle float32) []Segment
- func ArcSegment(start, center Point, angle float32) Segment
- func LinearSegment(a, b Point) Segment
- func QuadraticSegment(start, cp, end Point) Segment
Constants ¶
const ( FlatCap CapStyle = 0 RoundCap = 1 SquareCap = 2 TriangularCap = 3 )
const ( MiterJoin JoinStyle = 0 RoundJoin = 1 BevelJoin = 2 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Segment ¶
A Segment is a cubic bezier curve (or a line segment that has been converted into a bezier curve).
func AppendArc ¶
AppendArc appends one or more segments to dst, forming an arc of a circle starting at start, centered at center, and extending angle radians counterclockwise. For a clockwise arc, use a negative angle.
func AppendEllipticalArc ¶
AppendEllipticalArc appends one or more segments to dst, forming an arc of an ellipse starting at start, with foci at f1 and f2, and extending angle radians counterclockwise. For a clockwise arc, use a negative angle.
func ArcSegment ¶
ArcSegment returns a Segment that approximates an arc of a circle, starting at start, centered at center, and extending angle radians counterclockwise. For a clockwise arc, use a negative angle. The accuracy of the approximation drops off as the angle increases; using a single segment for an arc longer than half a circle (angle > π) is not recommended (use AppendArc instead).
func LinearSegment ¶
LinearSegment returns a line segment connecting a and b, in the form of a cubic bezier curve with collinear control points.
func QuadraticSegment ¶
QuadraticSegment converts a quadratic bezier segment to a cubic one.