path

package
v0.32.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package path provides internal path processing utilities.

Package path provides internal path processing utilities.

Index

Constants

View Source
const Tolerance = 0.1

Tolerance is the maximum distance from the curve for flattening.

Variables

This section is empty.

Functions

This section is empty.

Types

type Close

type Close struct{}

Close closes the path.

type CubicTo

type CubicTo struct{ Control1, Control2, Point Point }

CubicTo draws a cubic curve.

type Edge added in v0.21.1

type Edge struct {
	P0, P1 Point
}

Edge represents a line segment from P0 to P1.

func CollectEdges added in v0.21.1

func CollectEdges(elements []PathElement) []Edge

CollectEdges returns all edges from the path elements. This is a convenience function for cases where all edges are needed at once.

type EdgeIter added in v0.21.1

type EdgeIter struct {
	// contains filtered or unexported fields
}

EdgeIter iterates over edges in a path, correctly handling subpath boundaries. Unlike Flatten which returns a flat []Point list, EdgeIter never creates edges between separate subpaths - it properly closes each subpath to its own start point before moving to the next.

This follows the same pattern as tiny-skia's PathEdgeIter.

func NewEdgeIter added in v0.21.1

func NewEdgeIter(elements []PathElement) *EdgeIter

NewEdgeIter creates a new edge iterator for the given path elements.

func (*EdgeIter) Next added in v0.21.1

func (iter *EdgeIter) Next() *Edge

Next returns the next edge in the path, or nil when iteration is complete. Curves (QuadTo, CubicTo) are flattened to line segments automatically.

type LineTo

type LineTo struct{ Point Point }

LineTo draws a line.

type MoveTo

type MoveTo struct{ Point Point }

MoveTo moves to a point.

type PathElement

type PathElement interface {
	// contains filtered or unexported methods
}

PathElement represents an element in a path.

type Point

type Point struct {
	X, Y float64
}

Point represents a 2D point (internal copy to avoid import cycle).

func Flatten

func Flatten(elements []PathElement) []Point

Flatten converts a path with curves into a path with only straight lines.

func (Point) Add

func (p Point) Add(q Point) Point

func (Point) Distance

func (p Point) Distance(q Point) float64

func (Point) Dot

func (p Point) Dot(q Point) float64

func (Point) Length

func (p Point) Length() float64

func (Point) Lerp

func (p Point) Lerp(q Point, t float64) Point

Helper methods for Point

func (Point) Mul

func (p Point) Mul(s float64) Point

func (Point) Sub

func (p Point) Sub(q Point) Point

type QuadTo

type QuadTo struct{ Control, Point Point }

QuadTo draws a quadratic curve.

Jump to

Keyboard shortcuts

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