pub struct PolylineSampler { /* private fields */ }Expand description
Pre-flattened polyline with a cumulative segment-length table. Build once, then sample at arbitrary arc-length distances in O(N) per query.
Used when the caller needs irregular sampling — e.g. LineGeom
walking a linetype pattern where Dash / Gap / Marker steps consume
different amounts of arc length per step, or Phase D’s TextPathGeom
placing each glyph at the next-glyph-width along the path. For
regular fixed-step sampling use ArcLengthWalker instead.
Implementations§
Source§impl PolylineSampler
impl PolylineSampler
Sourcepub fn from_polyline(points: &[Point]) -> Self
pub fn from_polyline(points: &[Point]) -> Self
Build a sampler from a piecewise-linear point list. Zero-length
segments are dropped from the segment table but their start
point still anchors the sampler’s total_length == 0 case
behaviour.
Sourcepub fn from_path(path: &Path, tolerance: f64) -> Vec<Self>
pub fn from_path(path: &Path, tolerance: f64) -> Vec<Self>
Build one sampler per subpath of path, flattening curves with
tolerance.
Sourcepub fn from_closed_path(path: &Path, tolerance: f64) -> Vec<Self>
pub fn from_closed_path(path: &Path, tolerance: f64) -> Vec<Self>
Build one sampler per subpath of path, treating each subpath
as closed — the segment from the last vertex back to the
first is included in the total arc length. Use this for
walking the perimeter of a closed shape (Polygon / Rect /
Ellipse / Wedge) where the pattern should wrap continuously
around the boundary.
Sourcepub fn total_length(&self) -> f64
pub fn total_length(&self) -> f64
Total arc length of the polyline.
Sourcepub fn segment_boundaries_between(&self, start: f64, end: f64) -> Vec<f64>
pub fn segment_boundaries_between(&self, start: f64, end: f64) -> Vec<f64>
Cumulative distances at every interior original-segment
boundary strictly between start and end (exclusive on both
ends, with a small epsilon to avoid duplicates). Iterates in
arc-length order. Empty when end <= start or when no interior
boundary falls in the interval.
Useful for clients that need to draw a sub-polyline of the
sampler spanning [start, end] while preserving the original
polyline’s vertex set inside the interval (so collinear runs
remain a single segment).
Trait Implementations§
Source§impl Clone for PolylineSampler
impl Clone for PolylineSampler
Source§fn clone(&self) -> PolylineSampler
fn clone(&self) -> PolylineSampler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PolylineSampler
impl RefUnwindSafe for PolylineSampler
impl Send for PolylineSampler
impl Sync for PolylineSampler
impl Unpin for PolylineSampler
impl UnsafeUnpin for PolylineSampler
impl UnwindSafe for PolylineSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.