Struct pax_pixels::Path
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§
§impl Path
impl Path
pub 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.
pub fn svg_builder() -> WithSvg<BuilderImpl>
pub fn svg_builder() -> WithSvg<BuilderImpl>
Creates an WithSvg to build a path with a rich set of commands.
pub fn with_attributes(num_attributes: usize) -> Path
pub fn as_slice(&self) -> PathSlice<'_>
pub fn as_slice(&self) -> PathSlice<'_>
Returns a view on this Path.
pub fn attributes(&self, endpoint: EndpointId) -> &[f32]
pub fn attributes(&self, endpoint: EndpointId) -> &[f32]
Returns a slice over an endpoint’s custom attributes.
pub fn iter(&self) -> Iter<'_>
pub fn iter(&self) -> Iter<'_>
Iterates over the entire Path, ignoring custom attributes.
pub fn id_iter(&self) -> IdIter<'_>
pub fn id_iter(&self) -> IdIter<'_>
Iterates over the endpoint and control point ids of the Path.
pub fn iter_with_attributes(&self) -> IterWithAttributes<'_>
pub fn iter_with_attributes(&self) -> IterWithAttributes<'_>
Iterates over the entire Path with custom attributes.
pub fn transformed<T>(self, transform: &T) -> Pathwhere
T: Transformation<f32>,
pub fn transformed<T>(self, transform: &T) -> Pathwhere T: Transformation<f32>,
Applies a transform to all endpoints and control points of this path and Returns the result.
pub fn reversed(&self) -> NoAttributes<Reversed<'_>>
pub fn reversed(&self) -> NoAttributes<Reversed<'_>>
Returns a reversed version of this path in the form of an iterator
pub fn first_endpoint(&self) -> Option<(Point2D<f32, UnknownUnit>, &[f32])>
pub fn first_endpoint(&self) -> Option<(Point2D<f32, UnknownUnit>, &[f32])>
Returns the first endpoint and its custom attributes if any.
pub fn last_endpoint(&self) -> Option<(Point2D<f32, UnknownUnit>, &[f32])>
pub fn last_endpoint(&self) -> Option<(Point2D<f32, UnknownUnit>, &[f32])>
Returns the last endpoint and its custom attributes if any.