pub struct PathBuilder { /* private fields */ }Expand description
Records verbs/points and tracks bounds; build freezes into an Arc<Path>.
Implementations§
Source§impl PathBuilder
impl PathBuilder
pub fn new() -> Self
pub fn move_to(&mut self, p: impl Into<Point>) -> &mut Self
pub fn line_to(&mut self, p: impl Into<Point>) -> &mut Self
pub fn quad_to(&mut self, c: impl Into<Point>, p: impl Into<Point>) -> &mut Self
pub fn cubic_to( &mut self, c1: impl Into<Point>, c2: impl Into<Point>, p: impl Into<Point>, ) -> &mut Self
pub fn close(&mut self) -> &mut Self
pub fn rect(&mut self, r: Rect) -> &mut Self
Sourcepub fn rrect(&mut self, r: Rect, radius: f32) -> &mut Self
pub fn rrect(&mut self, r: Rect, radius: f32) -> &mut Self
Rounded rect with one radius for all corners (clamped to half-extent).
Sourcepub fn rrect_radii(&mut self, r: Rect, radii: [f32; 4]) -> &mut Self
pub fn rrect_radii(&mut self, r: Rect, radii: [f32; 4]) -> &mut Self
Per-corner CIRCULAR radii, clockwise from top-left: [tl, tr, br, bl] — the rx == ry case of Self::rrect_radii_elliptical.
Sourcepub fn rrect_radii_elliptical(
&mut self,
r: impl Into<Rect>,
radii: [[f32; 2]; 4],
) -> &mut Self
pub fn rrect_radii_elliptical( &mut self, r: impl Into<Rect>, radii: [[f32; 2]; 4], ) -> &mut Self
Per-corner ELLIPTICAL radii, clockwise from top-left: [[rx, ry]; 4] for [tl, tr, br, bl] — the full CSS/Flutter rounded-rect
(8 scalars). Radii are constrained together per axis (see
constrain_radii_elliptical).
Sourcepub fn rrect_radii_elliptical_wound(
&mut self,
r: impl Into<Rect>,
radii: [[f32; 2]; 4],
winding: Winding,
) -> &mut Self
pub fn rrect_radii_elliptical_wound( &mut self, r: impl Into<Rect>, radii: [[f32; 2]; 4], winding: Winding, ) -> &mut Self
The same rounded rectangle, traversed in a chosen direction.
Direction is not cosmetic: two overlapping contours with OPPOSITE
windings cancel under the non-zero fill rule, and dashing walks a
contour in order. Canvas2D’s roundRect reaches this — it is
specified on SIGNED extents, and mismatched signs mean
counter-clockwise, so normalizing the box without carrying the
direction silently turns a subtractive rectangle into an additive one.
Sourcepub fn arc(
&mut self,
center: impl Into<Point>,
radius: f32,
start_angle: f32,
sweep_angle: f32,
) -> &mut Self
pub fn arc( &mut self, center: impl Into<Point>, radius: f32, start_angle: f32, sweep_angle: f32, ) -> &mut Self
Circular arc — Canvas2D’s arc, the equal-radii case of
Self::ellipse. Angles are radians from the +x axis, and a
positive sweep_angle turns toward +y (clockwise on screen, since
valo is y-down).
Sourcepub fn ellipse(
&mut self,
center: impl Into<Point>,
radii: [f32; 2],
x_axis_rotation: f32,
start_angle: f32,
sweep_angle: f32,
) -> &mut Self
pub fn ellipse( &mut self, center: impl Into<Point>, radii: [f32; 2], x_axis_rotation: f32, start_angle: f32, sweep_angle: f32, ) -> &mut Self
Elliptical arc — Canvas2D’s ellipse. A negative radius draws
NOTHING (Canvas2D throws instead, and Skia takes the absolute value);
non-finite input is dropped the same way.
The ellipse has half-extents
radii, is turned by x_axis_rotation, and is swept from
start_angle for sweep_angle radians. Canvas2D semantics: an open
contour is joined to the arc’s first point by a straight line, and a
closed one starts there.
Each ≤90° piece is the classic k = 4/3·tan(Δ/4) cubic approximation —
the same construction Self::circle and the rounded-rect corners
already use. Skia represents arcs exactly, with conics; valo has only
quads and cubics, and the approximation’s radial error tops out near
2.7e-4 of the radius, under a tenth of a pixel below r ≈ 370.
Sourcepub fn arc_to(
&mut self,
corner: impl Into<Point>,
next: impl Into<Point>,
radius: f32,
) -> &mut Self
pub fn arc_to( &mut self, corner: impl Into<Point>, next: impl Into<Point>, radius: f32, ) -> &mut Self
Canvas2D’s arcTo: the circle of radius tangent to both the segment
running from the current point to corner and the one running from
corner to next, reached by a straight line. Degenerate input —
zero OR NEGATIVE radius, coincident points, a straight-through corner —
falls back to a line to corner, as the spec requires. (Canvas2D
throws on a negative radius; valo never throws from a path builder.)
pub fn circle(&mut self, center: impl Into<Point>, radius: f32) -> &mut Self
Sourcepub fn append(&mut self, path: &Path, transform: &Matrix) -> &mut Self
pub fn append(&mut self, path: &Path, transform: &Matrix) -> &mut Self
Append a finished path, each point carried through transform —
Canvas2D’s Path2D.addPath and SVG’s <use>. Verbs are copied
verbatim: the source is already flat verb data, so nothing has to be
re-derived, and a shear that no arc verb could express is harmless
because arcs became cubics when the source was built.
pub fn build(self) -> Arc<Path> ⓘ
Trait Implementations§
Source§impl Clone for PathBuilder
impl Clone for PathBuilder
Source§fn clone(&self) -> PathBuilder
fn clone(&self) -> PathBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more