Skip to main content

PathBuilder

Struct PathBuilder 

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

A fluent builder for Path.

Every method returns Self so a path can be assembled in one expression without a mutable borrow in the middle of a call chain.

Implementations§

Source§

impl PathBuilder

Inherent implementation of PathBuilder.

Source

pub fn new() -> Self

Returns an empty builder.

Source

pub fn fill_rule(self, rule: FillRule) -> Self

Sets the fill rule used when the path is built.

§Arguments
  • FillRule - A FillRule parameter.
Source

pub fn move_to(self, x: f32, y: f32) -> Self

Starts a new sub-path at the given point.

§Arguments
  • f32 - A 32-bit float (f32).
Source

pub fn line_to(self, x: f32, y: f32) -> Self

Appends a straight line segment.

§Arguments
  • f32 - A 32-bit float (f32).
Source

pub fn quad_to(self, control_x: f32, control_y: f32, x: f32, y: f32) -> Self

Appends a quadratic Bézier segment.

§Arguments
  • f32 - A 32-bit float (f32).
Source

pub fn cubic_to( self, control1_x: f32, control1_y: f32, control2_x: f32, control2_y: f32, x: f32, y: f32, ) -> Self

Appends a cubic Bézier segment.

§Arguments
  • f32 - A 32-bit float (f32).
Source

pub fn close(self) -> Self

Closes the current sub-path.

Source

pub fn arc( self, center_x: f32, center_y: f32, radius_x: f32, radius_y: f32, start_angle: f64, end_angle: f64, ) -> Self

Appends an elliptical arc centered at the given point.

start_angle and end_angle are measured in radians, clockwise from the positive x-axis (the y-axis points down, matching the Canvas2D and SVG conventions). The arc is approximated with cubic Bézier segments.

§Arguments
  • f32 - A 32-bit float (f32).
  • f64 - A 64-bit float (f64).
Source

pub fn ellipse( self, center_x: f32, center_y: f32, radius_x: f32, radius_y: f32, ) -> Self

Appends a full ellipse centered at the given point.

§Arguments
  • f32 - A 32-bit float (f32).
Source

pub fn rect(self, x: f32, y: f32, width: f32, height: f32) -> Self

Appends an axis-aligned rectangle.

§Arguments
  • f32 - A 32-bit float (f32).
Source

pub fn round_rect( self, x: f32, y: f32, width: f32, height: f32, radius: f32, ) -> Self

Appends a rectangle with rounded corners.

§Arguments
  • f32 - A 32-bit float (f32).
Source

pub fn polygon(self, points: &[Point]) -> Self

Appends a closed polygon through the given points.

§Arguments
  • &[Point] - Shared reference to a [Point].
Source

pub fn build(self) -> Path

Returns the finished path.

§Returns
  • Path - A Path value.

Trait Implementations§

Source§

impl Clone for PathBuilder

Source§

fn clone(&self) -> Self

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 Debug for PathBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PathBuilder

Default construction for PathBuilder.

Source§

fn default() -> Self

Constructs a default PathBuilder value.

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

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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more