svg_path/degeneracy

Degenerate and nearly-degenerate geometry cleanup.

Types

Errors returned by degeneracy cleanup helpers.

pub type Error {
  InvalidTolerance(tolerance: Float)
  PathError(error: svg_path.Error)
  ConvexHullError(error: convex_hull.Error)
}

Constructors

  • InvalidTolerance(tolerance: Float)

    The linearization tolerance must be finite and non-negative.

  • PathError(error: svg_path.Error)

    An underlying path operation failed.

  • ConvexHullError(error: convex_hull.Error)

    Convex-hull construction failed while normalizing degenerate segments.

Values

pub fn normalize_degenerate_segments(
  subpath: svg_path.Subpath,
  tolerance tolerance: Float,
) -> Result(svg_path.Subpath, Error)

Replace maximal contiguous line-degenerate windows in a subpath.

Each selected window preserves its start and end and the two longitudinal support extrema, ordered by their occurrence in the source. Intermediate local reversals need not be retained. Windows are considered from left to right. Their exact curve-preserving convex hull is grown one segment at a time, and the largest prefix certified to fit in a strip of the requested width is selected first. A 0.0 tolerance collapses a window only when its strip width is exactly zero.

Search Document