Struct rasterize::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(subpaths: Vec<SubPath>) -> Self

Create path from the list of sub-paths

source

pub fn empty() -> Self

Create empty path

source

pub fn is_empty(&self) -> bool

Check if the path is empty

source

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

Calculate winding number of a point

source

pub fn subpaths(&self) -> &[SubPath]

List of sub-paths

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(&self) -> 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 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, f: &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, fmt: &mut Formatter<'_>) -> Result

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

impl Extend<SubPath> for Path

source§

fn extend<T: IntoIterator<Item = SubPath>>(&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

§

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

§

type Item = &'a SubPath

The type of the elements being iterated over.
§

type IntoIter = <&'a Vec<SubPath> as IntoIterator>::IntoIter

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 IntoIterator for Path

§

type Item = SubPath

The type of the elements being iterated over.
§

type IntoIter = <Vec<SubPath> as IntoIterator>::IntoIter

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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> 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,

§

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§

default 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>,

§

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

§

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