Struct Path

Source
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§

Source§

impl Path

Source

pub fn builder() -> Builder

Creates a Builder to build a path.

Source

pub fn builder_with_attributes(num_attributes: usize) -> BuilderWithAttributes

Creates a BuilderWithAttributes to build a path with custom attributes.

Source

pub fn svg_builder() -> WithSvg<Builder>

Creates an WithSvg to build a path with a rich set of commands.

Source

pub fn new() -> Path

Creates an Empty Path.

Source

pub fn as_slice(&self) -> PathSlice<'_>

Returns a view on this Path.

Source

pub fn attributes(&self, endpoint: EndpointId) -> &[f32]

Returns a slice over an endpoint’s custom attributes.

Source

pub fn iter(&self) -> Iter<'_>

Iterates over the entire Path.

Source

pub fn id_iter(&self) -> IdIter<'_>

Iterates over the endpoint and control point ids of the Path.

Source

pub fn iter_with_attributes(&self) -> IterWithAttributes<'_>

Source

pub fn transformed<T>(self, transform: &T) -> Path
where T: Transformation<f32>,

Applies a transform to all endpoints and control points of this path and Returns the result.

Source

pub fn reversed(&self) -> Path

Returns a reversed version of this path with edge loops specified in the opposite order.

Trait Implementations§

Source§

impl AttributeStore for Path

Source§

fn get(&self, id: EndpointId) -> &[f32]

Returns the endpoint’s custom attributes as a slice of 32 bits floats. Read more
Source§

fn num_attributes(&self) -> usize

Returns the number of float attributes per endpoint. Read more
Source§

impl Clone for Path

Source§

fn clone(&self) -> Path

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Path

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Path

Source§

fn default() -> Path

Returns the “default value” for a type. Read more
Source§

impl FromIterator<Event<Point2D<f32, UnknownUnit>, Point2D<f32, UnknownUnit>>> for Path

Source§

fn from_iter<T>(iter: T) -> Path

Creates a value from an iterator. Read more
Source§

impl Index<ControlPointId> for Path

Source§

type Output = Point2D<f32, UnknownUnit>

The returned type after indexing.
Source§

fn index(&self, id: ControlPointId) -> &Point2D<f32, UnknownUnit>

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<EndpointId> for Path

Source§

type Output = Point2D<f32, UnknownUnit>

The returned type after indexing.
Source§

fn index(&self, id: EndpointId) -> &Point2D<f32, UnknownUnit>

Performs the indexing (container[index]) operation. Read more
Source§

impl<'l> IntoIterator for &'l Path

Source§

type Item = Event<Point2D<f32, UnknownUnit>, Point2D<f32, UnknownUnit>>

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'l>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Iter<'l>

Creates an iterator from a value. Read more
Source§

impl PositionStore for Path

Auto Trait Implementations§

§

impl Freeze for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnwindSafe for Path

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using data from the given World
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Component for T
where T: Send + Sync + 'static,