Skip to main content

PathBuilder

Struct PathBuilder 

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

PathBuilder records commands used to create an immutable Path.

Implementations§

Source§

impl PathBuilder

Source

pub fn new() -> PathBuilder

new creates an empty path builder.

Source

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

move_to starts a new contour at p.

Source

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

line_to adds a straight segment to p.

Source

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

quad_to adds a quadratic Bézier through control point c to p.

Source

pub fn conic_to( &mut self, c: impl Into<Point>, p: impl Into<Point>, weight: f32, ) -> &mut PathBuilder

conic_to adds a rational quadratic (a conic) through control point c to p.

A weight of 1 is an ordinary quadratic; cos(θ/2) traces a circular arc of sweep θ exactly, which is what the arc and rounded-rect helpers rely on. Stored weights are restricted to positive finite values so every curve stays inside its control hull — the invariant the record-time bounds rely on. Everything else lowers: a nonpositive weight draws a line, a non-finite weight the control polygon (the curve’s limit as the weight grows). Skia, by contrast, records negative weights as-is; nothing in valo’s builders or Canvas2D produces one.

Source

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

cubic_to adds a cubic Bézier through two control points to p.

Source

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

close adds a segment back to the current contour’s starting point.

It has no effect when no contour is open.

Source

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

rect adds a closed rectangular contour.

Source

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

rrect adds a closed rounded rectangle with one corner radius.

Source

pub fn rrect_radii(&mut self, r: Rect, radii: [f32; 4]) -> &mut PathBuilder

rrect_radii adds a rounded rectangle with circular corner radii.

radii is ordered clockwise from the top-left.

Source

pub fn rrect_radii_elliptical( &mut self, r: impl Into<Rect>, radii: [[f32; 2]; 4], ) -> &mut PathBuilder

rrect_radii_elliptical adds per-corner elliptical radii.

Each corner is [x_radius, y_radius], starting at the top-left. Radii are proportionally reduced when adjacent corners would overlap.

Source

pub fn rrect_radii_elliptical_wound( &mut self, r: impl Into<Rect>, radii: [[f32; 2]; 4], winding: Winding, ) -> &mut PathBuilder

rrect_radii_elliptical_wound adds a rounded rectangle with explicit winding.

Opposing contours cancel under FillRule::NonZero, and dashing follows this traversal order.

Source

pub fn rsuperellipse(&mut self, r: Rect, radius: f32) -> &mut PathBuilder

rsuperellipse adds a rounded superellipse with one corner radius.

The corner profile is the iOS “squircle”: circular near the diagonal, blending into the straight edges along a superellipse instead of meeting them abruptly the way a circular Self::rrect corner does.

Source

pub fn rsuperellipse_radii( &mut self, r: Rect, radii: [[f32; 2]; 4], ) -> &mut PathBuilder

rsuperellipse_radii adds a rounded superellipse with per-corner elliptical radii.

Each corner is [x_radius, y_radius], clockwise from the top-left. Radii are proportionally reduced when adjacent corners would overlap.

Source

pub fn arc( &mut self, center: impl Into<Point>, radius: f32, start_angle: f32, sweep_angle: f32, ) -> &mut PathBuilder

arc adds a circular arc.

Angles are radians clockwise from +x in Valo’s y-down coordinates. Sweeps are limited to one full turn.

Source

pub fn ellipse( &mut self, center: impl Into<Point>, radii: [f32; 2], x_axis_rotation: f32, start_angle: f32, sweep_angle: f32, ) -> &mut PathBuilder

ellipse adds an elliptical arc.

radii are the x and y half-extents, x_axis_rotation turns the ellipse, and angles are radians clockwise from +x. An active contour is connected to the arc’s first point. Sweeps are limited to one full turn.

Non-finite input is ignored. Negative radii trigger a debug assertion and are ignored in release builds.

Source

pub fn arc_to( &mut self, corner: impl Into<Point>, next: impl Into<Point>, radius: f32, ) -> &mut PathBuilder

arc_to rounds the corner between the current point, corner, and next.

Zero or negative radius, coincident points, and straight-through corners fall back to a line ending at corner.

Source

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

circle adds a closed circular contour.

Four conic quarters trace the circle exactly; the control points are the bounding box’s corners.

Source

pub fn append(&mut self, path: &Path, transform: &Matrix) -> &mut PathBuilder

append adds a transformed copy of another path.

The appended path’s final contour becomes the current contour for subsequent commands.

Source

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

build consumes the builder and returns a shared immutable 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,