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>, ) -> Self
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: Scalar,
close: bool,
) -> impl Iterator<Item = Line> + '_
pub fn flatten( &self, tr: Transform, flatness: Scalar, 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<()>
pub fn write_svg_path(&self, out: impl Write) -> Result<()>
Save path in SVG path format.
Sourcepub fn read_svg_path(input: impl Read) -> Result<Self>
pub fn read_svg_path(input: impl Read) -> Result<Self>
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<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'a> Extend<SubPath<'a>> for Path
impl<'a> Extend<SubPath<'a>> for Path
Source§fn extend<T: IntoIterator<Item = SubPath<'a>>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = SubPath<'a>>>(&mut self, iter: T)
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
)