pub struct Path { /* private fields */ }Expand description
A 2-D path storing a sequence of draw commands.
Use PathBuilder (or the inherent builder methods) to populate a path,
then call Path::fill or Path::stroke to rasterise it.
Implementations§
Source§impl Path
impl Path
Sourcepub fn with_fill_rule(self, rule: FillRule) -> Self
pub fn with_fill_rule(self, rule: FillRule) -> Self
Set the fill rule (consumes and returns self for chaining).
Sourcepub fn line_to(&mut self, p: Point) -> &mut Self
pub fn line_to(&mut self, p: Point) -> &mut Self
Add a straight line from the current point to p.
Sourcepub fn quad_to(&mut self, ctrl: Point, end: Point) -> &mut Self
pub fn quad_to(&mut self, ctrl: Point, end: Point) -> &mut Self
Add a quadratic Bézier curve with control point ctrl ending at end.
Sourcepub fn cubic_to(&mut self, c1: Point, c2: Point, end: Point) -> &mut Self
pub fn cubic_to(&mut self, c1: Point, c2: Point, end: Point) -> &mut Self
Add a cubic Bézier curve with control points c1/c2 ending at end.
Sourcepub fn close(&mut self) -> &mut Self
pub fn close(&mut self) -> &mut Self
Close the current sub-path (draw a line back to the last MoveTo).
Sourcepub fn flatten(&self, tolerance: f32) -> Vec<Vec<Point>>
pub fn flatten(&self, tolerance: f32) -> Vec<Vec<Point>>
Flatten all sub-paths to sequences of line vertices.
Returns one Vec<Point> per sub-path (contour). The last point of
each contour is not duplicated at the start; callers should treat the
contour as closed (connect last → first).
tolerance is the maximum chord-distance deviation allowed per Bézier
segment (in pixels). A value of 0.25 gives visually smooth curves.
Sourcepub fn fill(&self, fb: &mut Framebuffer, color: Color)
pub fn fill(&self, fb: &mut Framebuffer, color: Color)
Fill this path’s interior into fb using the configured fill rule.
A single Rasterizer is created for the duration of this call so
that scratch buffers are reused across all contours of the path.
Sourcepub fn stroke(&self, fb: &mut Framebuffer, style: &StrokeStyle, color: Color)
pub fn stroke(&self, fb: &mut Framebuffer, style: &StrokeStyle, color: Color)
Stroke this path into fb using the given style.
Each sub-path is stroked independently; closed sub-paths produce closed outlines (the cap style is ignored for closed paths).
A single Rasterizer is created for the duration of this call so
that scratch buffers are reused across all contours.
Sourcepub fn fill_clipped(&self, fb: &mut Framebuffer, color: Color, clip: ClipRect)
pub fn fill_clipped(&self, fb: &mut Framebuffer, color: Color, clip: ClipRect)
Fill this path’s interior, clipped to clip.
Uses fill_polygon_clipped so pixels outside clip are never written.
Anti-aliasing is enabled by default.
Sourcepub fn stroke_clipped(
&self,
fb: &mut Framebuffer,
style: &StrokeStyle,
color: Color,
clip: ClipRect,
)
pub fn stroke_clipped( &self, fb: &mut Framebuffer, style: &StrokeStyle, color: Color, clip: ClipRect, )
Stroke this path, clipped to clip.
Constructs the stroke polygon and fills it using fill_polygon_clipped.
Sourcepub fn fill_clipped_aa(
&self,
fb: &mut Framebuffer,
color: Color,
clip: ClipRect,
aa: bool,
)
pub fn fill_clipped_aa( &self, fb: &mut Framebuffer, color: Color, clip: ClipRect, aa: bool, )
Fill this path’s interior, clipped to clip, with explicit AA control.
When aa is false, edges are aliased (faster; no coverage blending).
A single Rasterizer is created for the duration of this call so
that scratch buffers are reused across all contours.
Sourcepub fn stroke_clipped_aa(
&self,
fb: &mut Framebuffer,
style: &StrokeStyle,
color: Color,
clip: ClipRect,
aa: bool,
)
pub fn stroke_clipped_aa( &self, fb: &mut Framebuffer, style: &StrokeStyle, color: Color, clip: ClipRect, aa: bool, )
Stroke this path, clipped to clip, with explicit AA control.
When aa is false, the stroke polygon edges are aliased.
A single Rasterizer is created for the duration of this call so
that scratch buffers are reused across all contours.
Trait Implementations§
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> 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> 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