{"modulePath":"github.com/andybalholm/stroke","version":"v0.0.0-20251027184313-5126dd7227a1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package stroke\n\nThe stroke package provides functions for stroking cubic bezier paths.\n\nUnlike 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.\n\nMany of the algorithms come from [https://pomax.github.io/bezierinfo/](https://pomax.github.io/bezierinfo/)\n\n## Constants\n\n```go\nconst (\n\tFlatCap       CapStyle = 0\n\tRoundCap               = 1\n\tSquareCap              = 2\n\tTriangularCap          = 3\n)\n```\n\n```go\nconst (\n\tMiterJoin JoinStyle = 0\n\tRoundJoin           = 1\n\tBevelJoin           = 2\n)\n```\n\n## Functions\n\n```go\nfunc Dash(path [][]Segment, pattern []float32, phase float32) [][]Segment\n```\nDash returns a dashed version of path, according to the pattern and phase specified.\n\n```go\nfunc Stroke(path [][]Segment, opt Options) [][]Segment\n```\nStroke returns outlines for the contours in path. Both in the parameter and in the return value, each element of the slice is a contour (a connected series of segments).\n\n## Types\n\n```go\ntype CapStyle int\n```\n\n```go\ntype JoinStyle int\n```\n\n```go\ntype Options struct {\n\tWidth      float32\n\tCap        CapStyle\n\tJoin       JoinStyle\n\tMiterLimit float32\n}\n```\n\n```go\ntype Point struct {\n\tX, Y float32\n}\n```\nA Point is a two dimensional point.\n\n```go\nfunc Pt(x, y float32) Point\n```\nPt is shorthand for Point{X: x, Y: y}.\n\n```go\nfunc (p Point) Add(p2 Point) Point\n```\nAdd return the point p+p2.\n\n```go\nfunc (p Point) Div(s float32) Point\n```\nDiv returns the vector p/s.\n\n```go\nfunc (p Point) Mul(s float32) Point\n```\nMul returns p scaled by s.\n\n```go\nfunc (p Point) String() string\n```\nString return a string representation of p.\n\n```go\nfunc (p Point) Sub(p2 Point) Point\n```\nSub returns the vector p-p2.\n\n```go\ntype Segment struct {\n\tStart    Point\n\tCP1, CP2 Point\n\tEnd      Point\n}\n```\nA Segment is a cubic bezier curve (or a line segment that has been converted into a bezier curve).\n\n```go\nfunc AppendArc(dst []Segment, start, center Point, angle float32) []Segment\n```\nAppendArc 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.\n\n```go\nfunc AppendEllipticalArc(dst []Segment, start, f1, f2 Point, angle float32) []Segment\n```\nAppendEllipticalArc 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.\n\n```go\nfunc ArcSegment(start, center Point, angle float32) Segment\n```\nArcSegment 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 \u003e π) is not recommended (use AppendArc instead).\n\n```go\nfunc LinearSegment(a, b Point) Segment\n```\nLinearSegment returns a line segment connecting a and b, in the form of a cubic bezier curve with collinear control points.\n\n```go\nfunc QuadraticSegment(start, cp, end Point) Segment\n```\nQuadraticSegment converts a quadratic bezier segment to a cubic one.\n\n```go\nfunc (s Segment) Split(t float32) (Segment, Segment)\n```\nSplit splits s into two segments with de Casteljau's algorithm, at t.\n\n```go\nfunc (s Segment) Split2(t1, t2 float32) Segment\n```\nSplit2 returns the section of s that lies between t1 and t2.\n\n","path":"github.com/andybalholm/stroke","name":"stroke","synopsis":"The stroke package provides functions for stroking cubic bezier paths.","isRedistributable":true}
