pub struct Segments { /* private fields */ }Expand description
An arena of segments, each of which is a cubic Bézier.
Segments are indexed by SegIdx and can be retrieved by indexing (i.e. with square brackets).
Implementations§
Source§impl Segments
impl Segments
Sourcepub fn indices(&self) -> impl Iterator<Item = SegIdx>
pub fn indices(&self) -> impl Iterator<Item = SegIdx>
Iterate over all indices that can be used to index into this arena.
Sourcepub fn segments(&self) -> impl Iterator<Item = &Segment>
pub fn segments(&self) -> impl Iterator<Item = &Segment>
Iterate over all segments in this arena.
Sourcepub fn oriented_start(&self, idx: SegIdx) -> Point
pub fn oriented_start(&self, idx: SegIdx) -> Point
Returns the starting point of the segment at idx, relative to the segment’s original orientation.
The segment itself is stored in sweep-line order (i.e. its starting point has the smaller y coordinate) regardless of the original orientation of the segment. Use this method to retrieve the segment’s original start point.
Sourcepub fn oriented_end(&self, idx: SegIdx) -> Point
pub fn oriented_end(&self, idx: SegIdx) -> Point
Returns the ending point of the segment at idx, relative to the segment’s original orientation.
The segment itself is stored in sweep-line order (i.e. its starting point has the smaller y coordinate) regardless of the original orientation of the segment. Use this method to retrieve the segment’s original end point.
Sourcepub fn contour_next(&self, idx: SegIdx) -> Option<SegIdx>
pub fn contour_next(&self, idx: SegIdx) -> Option<SegIdx>
Returns the index of the segment following idx.
If idx is part of a non-closed path and it is the last segment,
this returns None. If idx is part of a closed path, this will
always return Some, and you might need to be careful to avoid looping
infinitely.
Sourcepub fn contour_prev(&self, idx: SegIdx) -> Option<SegIdx>
pub fn contour_prev(&self, idx: SegIdx) -> Option<SegIdx>
Returns the index of the segment preceding idx.
If idx is part of a non-closed path and it is the first segment,
this returns None. If idx is part of a closed path, this will
always return Some, and you might need to be careful to avoid looping
infinitely.
Sourcepub fn positively_oriented(&self, idx: SegIdx) -> bool
pub fn positively_oriented(&self, idx: SegIdx) -> bool
Does the sweep-line orientation of idx agree with its original orientation?
Sourcepub fn add_points<P: Into<Point>>(&mut self, ps: impl IntoIterator<Item = P>)
pub fn add_points<P: Into<Point>>(&mut self, ps: impl IntoIterator<Item = P>)
Add a (non-closed) polyline to this arena.
Sourcepub fn add_closed_polylines<P: Into<Point>>(
&mut self,
ps: impl IntoIterator<Item = impl IntoIterator<Item = P>>,
)
pub fn add_closed_polylines<P: Into<Point>>( &mut self, ps: impl IntoIterator<Item = impl IntoIterator<Item = P>>, )
Add a collection of closed polylines to this arena.
This can be much faster than calling add_cycles repeatedly.
Sourcepub fn add_closed_polyline<P: Into<Point>>(
&mut self,
ps: impl IntoIterator<Item = P>,
)
pub fn add_closed_polyline<P: Into<Point>>( &mut self, ps: impl IntoIterator<Item = P>, )
Add a closed polyline to this arena.
Sourcepub fn add_bez_path(&mut self, p: &BezPath) -> Result<(), NonClosedPath>
pub fn add_bez_path(&mut self, p: &BezPath) -> Result<(), NonClosedPath>
Add a Bézier path to this arena.
The path can contain multiple subpaths, and each of them must be closed.
Sourcepub fn add_non_closed_bez_path(
&mut self,
p: &BezPath,
) -> Result<(), NonClosedPath>
pub fn add_non_closed_bez_path( &mut self, p: &BezPath, ) -> Result<(), NonClosedPath>
Add a Bézier path to this arena.
The path can contain multiple subpaths, and each of them may or may not be closed.
Sourcepub fn from_closed_polyline<P: Into<Point>>(
ps: impl IntoIterator<Item = P>,
) -> Self
pub fn from_closed_polyline<P: Into<Point>>( ps: impl IntoIterator<Item = P>, ) -> Self
Construct a segment arena from a single closed polyline.
Sourcepub fn entrances(&self) -> &[(f64, SegIdx)]
pub fn entrances(&self) -> &[(f64, SegIdx)]
All the entrance heights of segments, ordered by height.
Includes horizontal segments.
Sourcepub fn exits(&self) -> &[(f64, SegIdx)]
pub fn exits(&self) -> &[(f64, SegIdx)]
All the exit heights of segments, ordered by height.
Does not include horizontal segments.
Sourcepub fn check_invariants(&self)
pub fn check_invariants(&self)
Checks that we satisfy our internal invariants. For testing only.