pub struct Path { /* private fields */ }
Expand description
A simple path data structure.
Custom attributes
Paths can store a fixed number of extra f32
values per endpoint, called
“custom attributes” or “interpolated attributes” through the documentation.
These can be handy to represent arbitrary attributes such as variable colors,
line width, etc.
See also:
Representation
Paths contain two buffers:
- a buffer of commands (Begin, Line, Quadratic, Cubic, Close or End),
- and a buffer of pairs of floats that can be endpoints control points or custom attributes.
The order of storage for points is determined by the sequence of commands. Custom attributes (if any) always directly follow endpoints. If there is an odd number of attributes, the last float of the each attribute sequence is set to zero and is not used.
__________________________
| | | |
| Begin | Line |Quadratic| ...
|_______|______|_________|_
__________________________________________________________________________
| | | | | | | |
|start x,y|attributes| to x, y |attributes|ctrl x,y | to x, y |attributes| ...
|_________|__________|_________|__________|_________|_________|__________|_
Implementations
sourceimpl Path
impl Path
sourcepub fn builder_with_attributes(num_attributes: usize) -> BuilderWithAttributes
pub fn builder_with_attributes(num_attributes: usize) -> BuilderWithAttributes
Creates a BuilderWithAttributes to build a path with custom attributes.
sourcepub fn svg_builder() -> WithSvg<BuilderImpl>
pub fn svg_builder() -> WithSvg<BuilderImpl>
Creates an WithSvg to build a path with a rich set of commands.
sourcepub fn attributes(&self, endpoint: EndpointId) -> Attributes<'_>
pub fn attributes(&self, endpoint: EndpointId) -> Attributes<'_>
Returns a slice over an endpoint’s custom attributes.
sourcepub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'l>impl<'l> Iterator for Iter<'l> type Item = PathEvent;
pub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'l>impl<'l> Iterator for Iter<'l> type Item = PathEvent;
Iterates over the entire Path
, ignoring custom attributes.
sourcepub fn id_iter(&self) -> IdIter<'_>ⓘNotable traits for IdIter<'l>impl<'l> Iterator for IdIter<'l> type Item = IdEvent;
pub fn id_iter(&self) -> IdIter<'_>ⓘNotable traits for IdIter<'l>impl<'l> Iterator for IdIter<'l> type Item = IdEvent;
Iterates over the endpoint and control point ids of the Path
.
sourcepub fn iter_with_attributes(&self) -> IterWithAttributes<'_>ⓘNotable traits for IterWithAttributes<'l>impl<'l> Iterator for IterWithAttributes<'l> type Item = Event<(Point, Attributes<'l>), Point>;
pub fn iter_with_attributes(&self) -> IterWithAttributes<'_>ⓘNotable traits for IterWithAttributes<'l>impl<'l> Iterator for IterWithAttributes<'l> type Item = Event<(Point, Attributes<'l>), Point>;
Iterates over the entire Path
with custom attributes.
sourcepub fn transformed<T: Transformation<f32>>(self, transform: &T) -> Self
pub fn transformed<T: Transformation<f32>>(self, transform: &T) -> Self
Applies a transform to all endpoints and control points of this path and Returns the result.
sourcepub fn reversed(&self) -> IterNoAttributes<Reversed<'_>>ⓘNotable traits for NoAttributes<Iter>impl<'l, Iter> Iterator for NoAttributes<Iter> where
Iter: Iterator<Item = Event<(Point, Attributes<'l>), Point>>, type Item = PathEvent;
pub fn reversed(&self) -> IterNoAttributes<Reversed<'_>>ⓘNotable traits for NoAttributes<Iter>impl<'l, Iter> Iterator for NoAttributes<Iter> where
Iter: Iterator<Item = Event<(Point, Attributes<'l>), Point>>, type Item = PathEvent;
Iter: Iterator<Item = Event<(Point, Attributes<'l>), Point>>, type Item = PathEvent;
Returns a reversed version of this path in the form of an iterator
sourcepub fn first_endpoint(&self) -> Option<(Point, Attributes<'_>)>
pub fn first_endpoint(&self) -> Option<(Point, Attributes<'_>)>
Returns the first endpoint and its custom attributes if any.
sourcepub fn last_endpoint(&self) -> Option<(Point, Attributes<'_>)>
pub fn last_endpoint(&self) -> Option<(Point, Attributes<'_>)>
Returns the last endpoint and its custom attributes if any.
Trait Implementations
sourceimpl AttributeStore for Path
impl AttributeStore for Path
sourcefn get(&self, id: EndpointId) -> Attributes<'_>
fn get(&self, id: EndpointId) -> Attributes<'_>
Returns the endpoint’s custom attributes as a slice of 32 bits floats. Read more
sourcefn num_attributes(&self) -> usize
fn num_attributes(&self) -> usize
Returns the number of float attributes per endpoint. Read more
sourceimpl Index<ControlPointId> for Path
impl Index<ControlPointId> for Path
sourceimpl Index<EndpointId> for Path
impl Index<EndpointId> for Path
sourceimpl<'l> IntoIterator for &'l Path
impl<'l> IntoIterator for &'l Path
sourceimpl PositionStore for Path
impl PositionStore for Path
fn get_endpoint(&self, id: EndpointId) -> Point
fn get_control_point(&self, id: ControlPointId) -> Point
Auto Trait Implementations
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnwindSafe for Path
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more