svg_path/convex_hull
Convex hull helpers for paths, subpaths, segments, and points.
This module computes closed hulls. Lines, quadratic Beziers, and arcs have semantic hulls: the primitive itself plus the chord joining its endpoints, with tiny/point-like cases collapsed to lines. Cubic Beziers use a cubic-specific support/event solver.
Types
Errors returned by convex-hull construction.
pub type Error {
PathError(svg_path.Error)
ConstructionFailed
}
Constructors
-
PathError(svg_path.Error)An underlying path operation failed.
-
ConstructionFailedHull construction failed because an internal invariant was not satisfied.
Values
pub fn path_hull(
path: svg_path.Path,
) -> Result(svg_path.Subpath, Error)
Compute the convex hull of a path.
Move-only subpaths are treated as single points at their starts. The result is a single closed subpath containing the hull of every subpath in the input path.
pub fn points_hull(
points: List(svg_path.Point),
) -> Result(svg_path.Subpath, Error)
Compute the convex hull of a list of points.
The result is a single closed subpath containing every input point.
pub fn segment_hull(
segment: svg_path.Segment,
) -> Result(svg_path.Subpath, Error)
Return the closed convex hull boundary of one segment.
The returned subpath uses exact pieces of the input curve where they lie on the hull boundary and straight support chords between those pieces.
pub fn subpath_hull(
subpath: svg_path.Subpath,
) -> Result(svg_path.Subpath, Error)
Compute the convex hull of a subpath.
The result is a closed subpath. Move-only subpaths are treated as a single point at their start. Otherwise each individual segment is first converted to its own convex hull, then those convex loops are unioned one at a time.