Path2D

Struct Path2D 

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

A Path2D is a builder for Vec<PathOp>.

§Example

use footile::Path2D;

let path = Path2D::default()
    .move_to(10.0, 10.0)
    .line_to(90.0, 90.0)
    .finish();

Implementations§

Source§

impl Path2D

Source

pub fn absolute(self) -> Self

Use absolute coordinates for subsequent operations.

Source

pub fn relative(self) -> Self

Use relative coordinates for subsequent operations.

This is the default setting.

Source

pub fn close(self) -> Self

Close current sub-path and move pen to origin.

Source

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

Move the pen to a point.

  • x X-position of point.
  • y Y-position of point.
Source

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

Add a line from pen to a point.

  • x X-position of end point.
  • y Y-position of end point.
Source

pub fn quad_to(self, bx: f32, by: f32, cx: f32, cy: f32) -> Self

Add a quadratic bézier spline.

The points are:

  • Current pen position: Pa
  • Control point: Pb (bx / by)
  • Spline end point: Pc (cx / cy)
Source

pub fn cubic_to( self, bx: f32, by: f32, cx: f32, cy: f32, dx: f32, dy: f32, ) -> Self

Add a cubic bézier spline.

The points are:

  • Current pen position: Pa
  • First control point: Pb (bx / by)
  • Second control point: Pc (cx / cy)
  • Spline end point: Pd (dx / dy)
Source

pub fn pen_width(self, width: f32) -> Self

Set pen stroke width.

All subsequent path points will be affected, until the stroke width is changed again.

  • width Pen stroke width.
Source

pub fn finish(self) -> Vec<PathOp>

Finish path with specified operations.

Trait Implementations§

Source§

impl Default for Path2D

Source§

fn default() -> Path2D

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

Auto Trait Implementations§

§

impl Freeze for Path2D

§

impl RefUnwindSafe for Path2D

§

impl Send for Path2D

§

impl Sync for Path2D

§

impl Unpin for Path2D

§

impl UnwindSafe for Path2D

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