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.
Open subpaths are implicitly closed by a straight line for filling; those
closing lines are also included in the returned arrangement build.
Types
The stage at which classified boundary topology became inconsistent.
pub type BoundaryTopologyFailure {
SectorMismatch
TraceFailed
}
Constructors
-
SectorMismatchA boundary ray did not have the required filled-sector successor.
-
TraceFailedLinked 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 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.ArrangementSegmentBuild,
)
}
Constructors
-
CsgResult( path: svg_path.Path, build: arrangement.ArrangementSegmentBuild, )Arguments
- path
-
The reconstructed result path for the requested operation.
- build
-
The arrangement graph and source-ordered input segment images used to classify and reconstruct
path.
Errors returned by arrangement-graph CSG operations.
pub type Error {
ArrangementGraphError
PathError(error: svg_path.Error)
InternalBoundaryTopologyError(
vertex: Int,
reason: BoundaryTopologyFailure,
)
}
Constructors
-
ArrangementGraphErrorArrangement construction or validation failed.
-
PathError(error: 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. The legacy name minimum_chord denotes a size threshold: refined
pieces are discarded when their segment length upper bound is below it,
not merely when their endpoints are close. Both values must be finite and
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 segment-size threshold 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 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 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 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 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.