svg_path/csg

Boolean operations on filled SVG paths.

The using fill rule is part of the operation: both input paths are first interpreted as filled sets under that rule, the Boolean operation is applied to those sets, and the returned path fills as the resulting set under the same rule.

Open subpaths are treated as implicitly closed for fill purposes. Empty paths and move-only subpaths contribute no filled area.

The implementation preserves original segment types where possible. It splits original path segments at point intersections, classifies each resulting directed piece by the filled state on its left and right sides, orients retained pieces with the result interior on their left, and assembles closed subpaths from those retained pieces. Curved segments remain curved between real encounters; only implicit closing edges are added as lines. Coincident line edges are split at their overlap endpoints and resolved by deterministic boundary ownership rules.

Types

Options for path CSG operations.

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

Constructors

Values

pub fn default_options() -> Options

Return default CSG options.

pub fn difference(
  left: svg_path.Path,
  minus right: svg_path.Path,
  using fill_rule: svg_path.FillRule,
) -> Result(svg_path.Path, svg_path.Error)

Return a path whose fill is left minus right under using.

pub fn difference_with(
  left: svg_path.Path,
  minus right: svg_path.Path,
  using fill_rule: svg_path.FillRule,
  options options: Options,
) -> Result(svg_path.Path, svg_path.Error)

Return a path whose fill is left minus right using explicit options.

pub fn intersection(
  left: svg_path.Path,
  right: svg_path.Path,
  using fill_rule: svg_path.FillRule,
) -> Result(svg_path.Path, svg_path.Error)

Return a path whose fill is the intersection of two input paths under using.

pub fn intersection_with(
  left: svg_path.Path,
  right: svg_path.Path,
  using fill_rule: svg_path.FillRule,
  options options: Options,
) -> Result(svg_path.Path, svg_path.Error)

Return a path whose fill is the intersection of two input paths using explicit options.

pub fn union(
  left: svg_path.Path,
  right: svg_path.Path,
  using fill_rule: svg_path.FillRule,
) -> Result(svg_path.Path, svg_path.Error)

Return a path whose fill is the union of two input paths under using.

pub fn union_with(
  left: svg_path.Path,
  right: svg_path.Path,
  using fill_rule: svg_path.FillRule,
  options options: Options,
) -> Result(svg_path.Path, svg_path.Error)

Return a path whose fill is the union of two input paths using explicit options.

Search Document