Documentation
¶
Overview ¶
Package skpath is a port of the parts of tiny-skia-path 0.11 (Skia's SkPath, SkStroke and SkDashPath) the icon transform needs: path building, affine transforms, stroking into fill outlines, and dashing. Arithmetic stays in float32 with the same operation order as the Rust code so the emitted coordinates match it.
Index ¶
- Variables
- func ComputeResolutionScale(t Transform) float32
- type Builder
- func (b *Builder) Close()
- func (b *Builder) CubicTo(x1, y1, x2, y2, x, y float32)
- func (b *Builder) Finish() (*Path, bool)
- func (b *Builder) IsEmpty() bool
- func (b *Builder) LastPoint() (Point, bool)
- func (b *Builder) Len() int
- func (b *Builder) LineTo(x, y float32)
- func (b *Builder) MoveTo(x, y float32)
- func (b *Builder) QuadTo(x1, y1, x, y float32)
- type LineCap
- type LineJoin
- type Path
- func (p *Path) Bounds() Rect
- func (p *Path) ComputeTightBounds() (Rect, bool)
- func (p *Path) DashPath(d *StrokeDash, resScale float32) (*Path, bool)
- func (p *Path) Len() int
- func (p *Path) Segments() *segmentsIter
- func (p *Path) StrokePath(s Stroke, resScale float32) (*Path, bool)
- func (p *Path) Transform(ts Transform) (*Path, bool)
- type Point
- type Rect
- type Segment
- type SegmentKind
- type Stroke
- type StrokeDash
- type Transform
- func (t Transform) IsIdentity() bool
- func (t Transform) IsValid() bool
- func (t Transform) MapPoints(points []Point)
- func (t Transform) PostConcat(o Transform) Transform
- func (t Transform) PreConcat(o Transform) Transform
- func (t Transform) PreScale(sx, sy float32) Transform
- func (t Transform) PreTranslate(tx, ty float32) Transform
- func (t Transform) Scale() (float32, float32)
- type Verb
Constants ¶
This section is empty.
Variables ¶
var Identity = Transform{SX: 1, SY: 1}
Identity is the identity transform.
Functions ¶
func ComputeResolutionScale ¶
ComputeResolutionScale is PathStroker::compute_resolution_scale.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder accumulates a path (tiny-skia's PathBuilder, i.e. SkPath).
func (*Builder) Close ¶
func (b *Builder) Close()
Close closes the contour (never twice, never first).
func (*Builder) Finish ¶
Finish builds the path; false for fewer than two verbs or unbounded points.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is an immutable path with at least two verbs (tiny-skia's Path).
func (*Path) ComputeTightBounds ¶
ComputeTightBounds is Path::compute_tight_bounds.
func (*Path) DashPath ¶
func (p *Path) DashPath(d *StrokeDash, resScale float32) (*Path, bool)
DashPath is Path::dash.
func (*Path) StrokePath ¶
StrokePath is Path::stroke: the fill outline of the stroke.
type Rect ¶
type Rect struct{ Left, Top, Right, Bottom float32 }
Rect is a finite rectangle with left <= right and top <= bottom.
func RectFromLTRB ¶
RectFromLTRB validates and builds a rect.
func RectFromXYWH ¶
RectFromXYWH is RectFromLTRB(x, y, w+x, h+y).
type Segment ¶
type Segment struct {
Kind SegmentKind
P [3]Point
}
Segment is one iterated path segment; P holds its points (the target last).
type SegmentKind ¶
type SegmentKind uint8
SegmentKind tags a Segment.
const ( SegMove SegmentKind = iota SegLine SegQuad SegCubic SegClose )
The segment kinds.
type Stroke ¶
type Stroke struct {
Width float32
MiterLimit float32
LineCap LineCap
LineJoin LineJoin
Dash *StrokeDash
}
Stroke describes a stroke to outline.
type StrokeDash ¶
type StrokeDash struct {
// contains filtered or unexported fields
}
StrokeDash is a validated dash pattern.
func NewStrokeDash ¶
func NewStrokeDash(array []float32, offset float32) (*StrokeDash, bool)
NewStrokeDash is StrokeDash::new: an even-length, non-negative array with a positive sum and a finite offset.
type Transform ¶
type Transform struct {
SX, KY, KX, SY, TX, TY float32
}
Transform is an affine matrix (tiny-skia's Transform): x' = sx*x + kx*y + tx, y' = ky*x + sy*y + ty.
func (Transform) PostConcat ¶
PostConcat is other * self.
func (Transform) PreTranslate ¶
PreTranslate is self * translate(tx, ty).