Skip to main content

PathBuilder

Struct PathBuilder 

Source
pub struct PathBuilder { /* private fields */ }
Expand description

Records verbs/points and tracks bounds; build freezes into an Arc<Path>.

Implementations§

Source§

impl PathBuilder

Source

pub fn new() -> Self

Source

pub fn move_to(&mut self, p: impl Into<Point>) -> &mut Self

Source

pub fn line_to(&mut self, p: impl Into<Point>) -> &mut Self

Source

pub fn quad_to(&mut self, c: impl Into<Point>, p: impl Into<Point>) -> &mut Self

Source

pub fn cubic_to( &mut self, c1: impl Into<Point>, c2: impl Into<Point>, p: impl Into<Point>, ) -> &mut Self

Source

pub fn close(&mut self) -> &mut Self

Source

pub fn rect(&mut self, r: Rect) -> &mut Self

Source

pub fn rrect(&mut self, r: Rect, radius: f32) -> &mut Self

Rounded rect with one radius for all corners (clamped to half-extent).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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.)

Source

pub fn circle(&mut self, center: impl Into<Point>, radius: f32) -> &mut Self

Source

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.

Source

pub fn build(self) -> Arc<Path>

Trait Implementations§

Source§

impl Clone for PathBuilder

Source§

fn clone(&self) -> PathBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for PathBuilder

Source§

fn default() -> PathBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.