svg_path/csg

ArrangementGraph-based operations on SVG paths.

Binary operations interpret both operands with one fill rule. The unary nested_contours operation instead preserves the complete signed integer winding field and therefore takes no fill rule.

Types

The stage at which classified boundary topology became inconsistent.

pub type BoundaryTopologyFailure {
  SectorMismatch
  TraceFailed
}

Constructors

  • SectorMismatch

    A boundary ray did not have the required filled-sector successor.

  • TraceFailed

    Linked boundary edges did not form a complete closed cycle.

A CSG output together with the exact arrangement used to derive it.

Returning the build makes normalization and graph refinement visible to the caller: the result path follows the arrangement’s geometry rather than silently claiming the original input geometry as its source of truth.

pub type CsgResult {
  CsgResult(
    path: svg_path.Path,
    build: arrangement.ArrangementGraphBuild,
  )
}

Constructors

  • CsgResult(
      path: svg_path.Path,
      build: arrangement.ArrangementGraphBuild,
    )

    Arguments

    path

    The reconstructed result path for the requested operation.

    build

    The arrangement graph and source-ordered normalized input paths used to classify and reconstruct path.

Errors returned by arrangement-graph CSG operations.

pub type Error {
  ArrangementGraphError(arrangement.Error)
  PathError(svg_path.Error)
  InternalBoundaryTopologyError(
    vertex: Int,
    reason: BoundaryTopologyFailure,
  )
}

Constructors

  • ArrangementGraphError(arrangement.Error)

    Arrangement construction or validation failed.

  • PathError(svg_path.Error)

    An underlying path operation failed.

  • InternalBoundaryTopologyError(
      vertex: Int,
      reason: BoundaryTopologyFailure,
    )

    Boundary classification produced topology that could not be reconstructed. This indicates an internal consistency failure rather than invalid caller syntax.

Numeric options used while constructing and classifying an arrangement.

tolerance is a distance in path coordinates used for endpoint clustering, intersection and overlap detection, winding-side sampling, and final cycle joins. minimum_chord discards refined edge pieces whose endpoint chord is shorter than that distance. Both values must be greater than zero.

pub type Options {
  Options(tolerance: Float, minimum_chord: Float)
}

Constructors

  • Options(tolerance: Float, minimum_chord: Float)

Values

pub fn default_options() -> Options

Return default arrangement-graph CSG options.

The default tolerance is 0.000001 path-coordinate units and the default minimum chord is 0.00001 path-coordinate units.

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

Return left minus right under using.

Each operand is filled independently using the supplied rule. The result follows the normalized and refined geometry exposed through CsgResult.build.

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

Return left minus right using explicit arrangement options.

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

Return the Boolean intersection of two paths under using.

Each operand is filled independently using the supplied rule. The result follows the normalized and refined geometry exposed through CsgResult.build.

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

Return the Boolean intersection using explicit arrangement options.

pub fn nested_contours(
  path: svg_path.Path,
) -> Result(CsgResult, Error)

Return nested or disjoint unit-level contours with the same signed winding field as path.

This operation preserves signed integer winding levels rather than applying a fill rule. The result follows the normalized and refined geometry exposed through CsgResult.build.

pub fn nested_contours_with(
  path: svg_path.Path,
  options options: Options,
) -> Result(CsgResult, Error)

Return nested contours using explicit arrangement options.

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

Return the Boolean symmetric difference of two paths under using.

Each operand is filled independently using the supplied rule. The result follows the normalized and refined geometry exposed through CsgResult.build.

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

Return the Boolean symmetric difference using explicit arrangement options.

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

Return the Boolean union of two paths under using.

Each operand is filled independently using the supplied rule. The result follows the normalized and refined geometry exposed through CsgResult.build.

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

Return the Boolean union using explicit arrangement options.

Search Document