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
impl Path
pub fn new( segments: Vec<Segment>, subpaths: Vec<usize>, closed: Vec<bool>, ) -> Path
Sourcepub fn winding_at(&self, point: impl Into<Point>) -> i32
pub fn winding_at(&self, point: impl Into<Point>) -> i32
Calculate winding number of a point
pub fn push(&mut self, segments: &[Segment], closed: bool)
Sourcepub fn builder() -> PathBuilder
pub fn builder() -> PathBuilder
Convenience method to create PathBuilder
Sourcepub fn into_builder(self) -> PathBuilder
pub fn into_builder(self) -> PathBuilder
Convert path into a path builder so it can be extended
Sourcepub fn segments_count(&self) -> usize
pub fn segments_count(&self) -> usize
Number of segments in the path
Sourcepub fn stroke(&self, style: StrokeStyle) -> Path
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.
Sourcepub fn flatten(
&self,
tr: Transform,
flatness: f64,
close: bool,
) -> impl Iterator<Item = Line>
pub fn flatten( &self, tr: Transform, flatness: f64, close: bool, ) -> impl Iterator<Item = Line>
Convert path to an iterator over line segments
Sourcepub fn bbox(&self, tr: Transform) -> Option<BBox>
pub fn bbox(&self, tr: Transform) -> Option<BBox>
Bounding box of the path after provided transformation is applied.
Sourcepub fn size(&self, tr: Transform) -> Option<(Size, Transform, Point)>
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
Sourcepub fn fill<R, P, I>(
&self,
rasterizer: R,
tr: Transform,
fill_rule: FillRule,
paint: P,
img: I,
) -> I
pub fn fill<R, P, I>( &self, rasterizer: R, tr: Transform, fill_rule: FillRule, paint: P, img: I, ) -> I
Fill path with the provided paint
Sourcepub fn mask<R, I>(
&self,
rasterizer: R,
tr: Transform,
fill_rule: FillRule,
img: I,
) -> I
pub fn mask<R, I>( &self, rasterizer: R, tr: Transform, fill_rule: FillRule, img: I, ) -> I
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.
Sourcepub fn write_svg_path(&self, out: impl Write) -> Result<(), Error>
pub fn write_svg_path(&self, out: impl Write) -> Result<(), Error>
Save path in SVG path format.
Sourcepub fn read_svg_path(input: impl Read) -> Result<Path, Error>
pub fn read_svg_path(input: impl Read) -> Result<Path, Error>
Load path from SVG path representation
pub fn display(&self, relative: bool, tr: Transform) -> PathSvgDisplay<'_>
Sourcepub fn verbose_debug(&self) -> PathVerboseDebug<'_>
pub fn verbose_debug(&self) -> PathVerboseDebug<'_>
Returns struct that prints command per line on debug formatting.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Path
impl<'de> Deserialize<'de> for Path
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Path, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Path, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'a> Extend<SubPath<'a>> for Path
impl<'a> Extend<SubPath<'a>> for Path
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = SubPath<'a>>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = SubPath<'a>>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<'a> IntoIterator for &'a Path
impl<'a> IntoIterator for &'a Path
Source§impl Serialize for Path
impl Serialize for Path
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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