svg_path/clip

Curve clipping helpers.

These functions clip path geometry, not filled areas. The clipping region is interpreted as a filled Path, but the input geometry is interpreted as curves to keep or discard. Returned subpaths contain only pieces of the original input geometry; no bridge segments from the clipping boundary are inserted.

Types

Options for curve clipping.

pub type Options {
  Options(
    intersection: intersections.IntersectionOptions,
    containment: svg_path.ContainmentOptions,
    tolerance: Float,
  )
}

Constructors

  • Options(
      intersection: intersections.IntersectionOptions,
      containment: svg_path.ContainmentOptions,
      tolerance: Float,
    )

    Arguments

    intersection

    Options used to locate clipping-boundary intersections.

    containment

    Options used to classify pieces against the filled clipping region.

    tolerance

    Path-coordinate tolerance used to deduplicate cut parameters.

Values

pub fn default_options() -> Options

Return default clipping options.

Intersection and containment use their module defaults; cut parameters are deduplicated with a 0.000001 path-coordinate tolerance.

pub fn path(
  input: svg_path.Path,
  to clip_region: svg_path.Path,
  using fill_rule: svg_path.FillRule,
) -> Result(svg_path.Path, svg_path.Error)

Clip every subpath in input to the filled clip_region.

The result keeps only portions of the original input geometry whose sample point is inside or on the boundary of the clipping region. Open inputs may produce zero or more open subpaths. Closed inputs may also produce open subpaths when the clipping boundary cuts them; a closed input remains closed only when it survives whole.

pub fn path_with(
  input: svg_path.Path,
  to clip_region: svg_path.Path,
  using fill_rule: svg_path.FillRule,
  options options: Options,
) -> Result(svg_path.Path, svg_path.Error)

Clip every subpath in input using explicit options.

pub fn subpath(
  input: svg_path.Subpath,
  to clip_region: svg_path.Path,
  using fill_rule: svg_path.FillRule,
) -> Result(List(svg_path.Subpath), svg_path.Error)

Clip one subpath to the filled clip_region.

Returned subpaths preserve traversal order. No closing or bridge segments are added at clipping-boundary crossings.

pub fn subpath_with(
  input: svg_path.Subpath,
  to clip_region: svg_path.Path,
  using fill_rule: svg_path.FillRule,
  options options: Options,
) -> Result(List(svg_path.Subpath), svg_path.Error)

Clip one subpath using explicit options.

Search Document