svg_path/intersections
Point-intersection queries for SVG path geometry.
This module owns segment, subpath, path, and self-intersection search.
Result types are the root svg_path types, such as
svg_path.SegmentIntersection, svg_path.SubpathIntersection, and
svg_path.PathIntersection.
Types
Options for finding segment, subpath, and path intersections.
pub type IntersectionOptions {
IntersectionOptions(tolerance: Float, max_depth: Int)
}
Constructors
-
IntersectionOptions(tolerance: Float, max_depth: Int)
Values
pub fn default_options() -> IntersectionOptions
Return the default options for segment, subpath, and path intersection detection.
pub fn default_self_options() -> svg_path.SelfIntersectionOptions
Return the default options for subpath self-intersection detection.
pub fn path(
left: svg_path.Path,
right: svg_path.Path,
) -> Result(List(svg_path.PathIntersection), svg_path.Error)
Return the point intersections between two paths.
Each result contains an intersection point and every corresponding parameter on both paths. Results are ordered by the first left parameter. Segment-boundary aliases are canonicalized to one traversal address.
pub fn path_self(
path: svg_path.Path,
) -> Result(List(svg_path.PathSelfIntersection), svg_path.Error)
Return point intersections where a path intersects itself.
This includes self-intersections inside one subpath and intersections between distinct subpaths in the same path. Results are ordered by the first path parameter.
pub fn path_self_with(
path: svg_path.Path,
options options: svg_path.SelfIntersectionOptions,
) -> Result(List(svg_path.PathSelfIntersection), svg_path.Error)
Return point intersections where a path intersects itself using explicit options.
pub fn path_with(
left: svg_path.Path,
right: svg_path.Path,
options options: IntersectionOptions,
) -> Result(List(svg_path.PathIntersection), svg_path.Error)
Return the point intersections between two paths using explicit options.
pub fn segment(
left: svg_path.Segment,
right: svg_path.Segment,
) -> Result(List(svg_path.SegmentIntersection), svg_path.Error)
Return point intersections between two segments.
Overlapping segments return OverlappingSegments, since they have more than
a finite list of point intersections.
pub fn segment_self(
segment: svg_path.Segment,
) -> Result(List(svg_path.SegmentIntersection), svg_path.Error)
Return point intersections where a segment intersects itself.
Straight lines and quadratic Beziers do not report self-intersections. Cubic Beziers can self-intersect, including at separated parameters that evaluate to the same endpoint. An arc whose start and end coincide reports that endpoint pair when both radii are nonzero.
pub fn segment_self_with(
segment: svg_path.Segment,
options options: svg_path.SelfIntersectionOptions,
) -> Result(List(svg_path.SegmentIntersection), svg_path.Error)
Return point intersections where a segment intersects itself using explicit options.
pub fn segment_subpath(
segment: svg_path.Segment,
subpath: svg_path.Subpath,
) -> Result(
List(#(svg_path.Point, Float, List(svg_path.SubpathParameter))),
svg_path.Error,
)
Return the intersections between a segment and a subpath.
Each result contains an intersection point, its local parameter on the standalone segment, and every corresponding parameter on the subpath. Results are ordered by the standalone segment parameter. Segment-boundary aliases are canonicalized to one traversal address.
pub fn segment_subpath_with(
segment: svg_path.Segment,
subpath: svg_path.Subpath,
options options: IntersectionOptions,
) -> Result(
List(#(svg_path.Point, Float, List(svg_path.SubpathParameter))),
svg_path.Error,
)
Return the intersections between a segment and a subpath using explicit options.
pub fn segment_with(
left: svg_path.Segment,
right: svg_path.Segment,
options options: IntersectionOptions,
) -> Result(List(svg_path.SegmentIntersection), svg_path.Error)
Return point intersections between two segments using explicit options.
pub fn subpath(
left: svg_path.Subpath,
right: svg_path.Subpath,
) -> Result(List(svg_path.SubpathIntersection), svg_path.Error)
Return the point intersections between two subpaths.
Each result contains an intersection point and every corresponding parameter on both subpaths. Results are ordered by the first left parameter. Segment-boundary aliases are canonicalized to one traversal address.
pub fn subpath_self(
subpath: svg_path.Subpath,
) -> Result(
List(svg_path.SubpathSelfIntersection),
svg_path.Error,
)
Return point intersections where a subpath intersects itself.
Results are ordered by the first parameter. Adjacent segment endpoints are filtered by arc-length separation, so ordinary segment joins are not reported as self-intersections.
pub fn subpath_self_with(
subpath: svg_path.Subpath,
options options: svg_path.SelfIntersectionOptions,
) -> Result(
List(svg_path.SubpathSelfIntersection),
svg_path.Error,
)
Return point intersections where a subpath intersects itself using explicit options.
pub fn subpath_with(
left: svg_path.Subpath,
right: svg_path.Subpath,
options options: IntersectionOptions,
) -> Result(List(svg_path.SubpathIntersection), svg_path.Error)
Return the point intersections between two subpaths using explicit options.