Skip to main content

Path

Struct Path 

Source
pub struct Path { /* private fields */ }
Expand description

Represents a geometric path, composed of one or more subpaths.

A Path can be created from an SVG path string and can be iterated over to process its individual subpaths. It also provides utilities for analyzing path properties, such as finding the outermost contour.

Implementations§

Source§

impl Path

Source

pub fn iter(&self) -> impl Iterator<Item = Path> + '_

Returns an iterator over the subpaths of this path.

Each item in the iterator is a Path representing a single subpath.

Source

pub fn is_closed(&self) -> bool

Checks if the path is closed.

A path is considered closed if it ends with a Close event.

Source

pub fn find_outer_shell(&self) -> Option<Path>

Find and return the subpath that represents the outermost shell.

This method first attempts to use a fast “largest area” heuristic. If that fails to produce a result, it falls back to a more accurate but slower “geometric containment” algorithm.

§Returns

An Option<Path> containing the outermost shell if found, otherwise None.

Trait Implementations§

Source§

impl Clone for Path

Source§

fn clone(&self) -> Path

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Path

Source§

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

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

impl Display for Path

Formats the Path as an SVG path data string.

Source§

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

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

impl From<&(Coord2, Vec<(Coord2, Coord2, Coord2)>)> for Path

Converts a flo_curves::SimpleBezierPath back into a Path.

This reconstructs a lyon path from the flo_curves representation. It handles both lines and cubic curves. The resulting path is explicitly closed by adding a line segment back to the start point and calling close().

Source§

fn from(value: &SimpleBezierPath) -> Self

Converts to this type from the input type.
Source§

impl From<&Path> for SimpleBezierPath

Converts a reference to a Path into a flo_curves::SimpleBezierPath.

This conversion processes the lyon::path::Event stream of the input path:

  • Event::Line, Event::Cubic: Translated directly to flo_curves equivalents.
  • Event::Quadratic: Mathematically converted into a cubic Bézier curve, as flo_curves primarily works with cubic curves.
  • Event::End: If the path is not marked as closed by lyon, a closing line segment is added to ensure the flo_curves path is properly closed, which is often a requirement for path algorithms.
Source§

fn from(path: &Path) -> SimpleBezierPath

Converts to this type from the input type.
Source§

impl From<&Vec<Curve<Coord2>>> for Path

Converts a vector of flo_curves::Curves into a Path.

Each Curve is assumed to be a cubic Bézier segment. The conversion creates a new Path where each curve becomes a separate, unclosed subpath consisting of a single cubic Bézier segment.

Source§

fn from(value: &Vec<Curve<Coord2>>) -> Self

Converts to this type from the input type.
Source§

impl From<Path> for Path

Converts a lyon::path::Path into this crate’s Path type.

Since crate::path::Path is a wrapper around lyon::path::Path, this is a straightforward conversion.

Source§

fn from(value: Path) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Path

Parses a Path from an SVG path data string.

§Errors

Returns a PathError if the SVG path data is invalid.

Source§

type Err = PathError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<'a> IntoIterator for &'a Path

Implements the IntoIterator trait for references to our Path type.

This is what allows a &Path to be used directly in a for loop, transparently creating a SubpathIter to drive the iteration.

Source§

fn into_iter(self) -> Self::IntoIter

Defines how to create a SubpathIter from a &Path.

Source§

type Item = Path

The type of the elements being iterated over.
Source§

type IntoIter = SubpathIter<'a>

Which kind of iterator are we turning this into?

Auto Trait Implementations§

§

impl Freeze for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnsafeUnpin 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.