Struct Path

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

Collection of the SubPath treated as a single unit. Represents the same concept as an SVG path

Implementations§

Source§

impl Path

Source

pub fn new( segments: Vec<Segment>, subpaths: Vec<usize>, closed: Vec<bool>, ) -> Self

Source

pub fn empty() -> Self

Create empty path

Source

pub fn is_empty(&self) -> bool

Check if the path is empty

Source

pub fn len(&self) -> usize

Number of sub-paths in the path

Source

pub fn winding_at(&self, point: impl Into<Point>) -> i32

Calculate winding number of a point

Source

pub fn get(&self, index: usize) -> Option<SubPath<'_>>

Get sub-path

Source

pub fn subpaths(&self) -> PathIter<'_>

List of sub-paths

Source

pub fn push(&mut self, segments: &[Segment], closed: bool)

Source

pub fn builder() -> PathBuilder

Convenience method to create PathBuilder

Source

pub fn into_builder(self) -> PathBuilder

Convert path into a path builder so it can be extended

Source

pub fn transform(&mut self, tr: Transform)

Apply transformation to the path in place

Source

pub fn segments_count(&self) -> usize

Number of segments in the path

Source

pub fn stroke(&self, style: StrokeStyle) -> Path

Stroke path

Stroked path is the path constructed from original by offsetting by distance/2 and joining it with the path offset by -distance/2.

Source

pub fn flatten( &self, tr: Transform, flatness: Scalar, close: bool, ) -> impl Iterator<Item = Line> + '_

Convert path to an iterator over line segments

Source

pub fn bbox(&self, tr: Transform) -> Option<BBox>

Bounding box of the path after provided transformation is applied.

Source

pub fn size(&self, tr: Transform) -> Option<(Size, Transform, Point)>

Calculate size of the image required to render the path

Returns:

  • Size of the image
  • Transformation required
  • Position of lowest x and y point of the image
Source

pub fn reverse(&mut self)

Reverse order and direction of all segments

Source

pub fn fill<R, P, I>( &self, rasterizer: R, tr: Transform, fill_rule: FillRule, paint: P, img: I, ) -> I
where R: Rasterizer, P: Paint, I: ImageMut<Pixel = LinColor>,

Fill path with the provided paint

Source

pub fn mask<R, I>( &self, rasterizer: R, tr: Transform, fill_rule: FillRule, img: I, ) -> I
where R: Rasterizer, I: ImageMut<Pixel = Scalar>,

Rasterize mast for the path in into a provided image.

Everything that is outside of the image will be cropped. Image is assumed to contain zeros.

Source

pub fn write_svg_path(&self, out: impl Write) -> Result<()>

Save path in SVG path format.

Source

pub fn read_svg_path(input: impl Read) -> Result<Self>

Load path from SVG path representation

Source

pub fn display(&self, relative: bool, tr: Transform) -> PathSvgDisplay<'_>

Source

pub fn verbose_debug(&self) -> PathVerboseDebug<'_>

Returns struct that prints command per line on debug formatting.

Trait Implementations§

Source§

impl Clone for Path

Source§

fn clone(&self) -> Path

Returns a copy 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, out: &mut Formatter<'_>) -> Result

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<'de> Deserialize<'de> for Path

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Path

Source§

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

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

impl<'a> Extend<SubPath<'a>> for Path

Source§

fn extend<T: IntoIterator<Item = SubPath<'a>>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl FromStr for Path

Source§

type Err = SvgParserError

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

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

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

impl<'a> IntoIterator for &'a Path

Source§

type Item = SubPath<'a>

The type of the elements being iterated over.
Source§

type IntoIter = PathIter<'a>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Path

Source§

fn eq(&self, other: &Path) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Path

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq 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> 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> 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,