svg_path/convex_hull

Convex hull helpers for paths, subpaths, and segments.

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

pub type HullError {
  PathError(svg_path.Error)
  ConsecutiveCurves
  DuplicateAdjacentTValues
  RefinementReachedMaxIterations(Int)
  PurificationReachedMaxIterations(Int)
}

Constructors

  • PathError(svg_path.Error)

    The generated hull segments could not be converted into a valid closed Subpath.

  • ConsecutiveCurves

    The final hull-piece sequence failed the invariant that curve pieces must be separated by line pieces.

  • DuplicateAdjacentTValues

    The refined support samples still contained adjacent duplicate segment parameters.

  • RefinementReachedMaxIterations(Int)

    Support-sample refinement did not settle before the iteration limit.

  • PurificationReachedMaxIterations(Int)

    Support-sample simplification did not settle before the iteration limit.

Values

pub fn path_hull(
  path: svg_path.Path,
) -> Result(svg_path.Subpath, HullError)

Compute the convex hull of all segments in a path.

Empty subpaths are ignored. The result is a single closed subpath containing the hull of every non-empty subpath in the input path.

pub fn segment_hull(
  segment: svg_path.Segment,
) -> Result(svg_path.Subpath, HullError)
pub fn subpath_hull(
  subpath: svg_path.Subpath,
) -> Result(svg_path.Subpath, HullError)

Compute the convex hull of all segments in a subpath.

The result is a closed subpath. Each individual segment is first converted to its own convex hull, then those convex loops are unioned one at a time.

Search Document