PathBuilder

Struct PathBuilder 

Source
pub struct PathBuilder {
    pub raw: WithSvg<BuilderImpl>,
}
Expand description

A Path builder.

Once a Path is built, it can no longer be mutated.

Fields§

§raw: WithSvg<BuilderImpl>

Implementations§

Source§

impl PathBuilder

Source

pub fn new() -> Self

Creates a new [Builder].

Source

pub fn move_to(self, point: Point) -> Self

Moves the starting point of a new sub-path to the given Point.

Source

pub fn line_to(self, point: Point) -> Self

Connects the last point in the Path to the given Point with a straight line.

Source

pub fn arc(self, arc: ArcPath) -> Self

Adds an [Arc] to the Path from start_angle to end_angle in a clockwise direction.

Source

pub fn arc_to(self, a: Point, b: Point, radius: f32) -> Self

Adds a circular arc to the Path with the given control points and radius.

This essentially draws a straight line segment from the current position to a, but fits a circular arc of radius tangent to that segment and tangent to the line between a and b.

With another .line_to(b), the result will be a path connecting the starting point and b with straight line segments towards a and a circular arc smoothing out the corner at a.

See the HTML5 specification of arcTo for more details and examples.

Source

pub fn ellipse(self, arc: EllipticalArcPath) -> Self

Adds an ellipse to the Path using a clockwise direction.

Source

pub fn bezier_curve_to( self, control_a: Point, control_b: Point, to: Point, ) -> Self

Adds a cubic Bézier curve to the Path given its two control points and its end point.

Source

pub fn quadratic_curve_to(self, control: Point, to: Point) -> Self

Adds a quadratic Bézier curve to the Path given its control point and its end point.

Source

pub fn rectangle(self, top_left: Point, size: Size) -> Self

Adds a rectangle to the Path given its top-left corner coordinate and its Size.

Source

pub fn circle(self, center: Point, radius: f32) -> Self

Adds a circle to the Path given its center coordinate and its radius.

Source

pub fn close(self) -> Self

Closes the current sub-path in the Path with a straight line to the starting point.

Source

pub fn build(self) -> Path

Builds the Path of this PathBuilder.

Trait Implementations§

Source§

impl Default for PathBuilder

Source§

fn default() -> Self

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