Skip to main content

Path

Struct Path 

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

a path: subpaths of lines and cubic curves, built once and drawn on any canvas (Canvas::append_path) or built on the canvas itself (its move_to, line_to, …)

Implementations§

Source§

impl Path

Source

pub fn new() -> Path

Source

pub fn is_empty(&self) -> bool

Source

pub fn clear(&mut self)

Source

pub fn current(&self) -> Option<(f64, f64)>

the current point (None before the first move_to and after clear)

Source

pub fn move_to(&mut self, x: f64, y: f64) -> &mut Path

starts a subpath

Source

pub fn line_to(&mut self, x: f64, y: f64) -> &mut Path

a straight line from the current point (without one: a move_to)

Source

pub fn curve_to( &mut self, x1: f64, y1: f64, x2: f64, y2: f64, x: f64, y: f64, ) -> &mut Path

a cubic Bézier curve with control points (x1, y1) and (x2, y2) to (x, y)

Source

pub fn quad_to(&mut self, x1: f64, y1: f64, x: f64, y: f64) -> &mut Path

a quadratic Bézier curve (written as the same cubic)

Source

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

closes the subpath with a line to its start

Source

pub fn rect(&mut self, x: f64, y: f64, w: f64, h: f64) -> &mut Path

a closed rectangle as its own subpath (PDF re)

Source

pub fn ellipse(&mut self, cx: f64, cy: f64, rx: f64, ry: f64) -> &mut Path

a closed ellipse around (cx, cy) as four cubic curves

Source

pub fn circle(&mut self, cx: f64, cy: f64, r: f64) -> &mut Path

Source

pub fn rounded_rect( &mut self, x: f64, y: f64, w: f64, h: f64, r: f64, ) -> &mut Path

a closed rectangle with corners rounded by r (at most half the shorter side)

Source

pub fn arc( &mut self, cx: f64, cy: f64, rx: f64, ry: f64, start: f64, sweep: f64, ) -> &mut Path

an elliptical arc around (cx, cy) from angle start over sweep radians (positive: from +x towards +y), as cubic curves of at most 90 degrees; it continues the subpath with a line to its start, or starts one

Source

pub fn append(&mut self, other: &Path) -> &mut Path

appends another path’s subpaths

Source

pub fn transform(&mut self, m: &Matrix)

every point mapped by m (a rectangle becomes four lines when m turns it)

Trait Implementations§

Source§

impl Clone for Path

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 Path

Source§

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

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

impl Default for Path

Source§

fn default() -> Self

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

impl PartialEq for Path

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Path

Auto Trait Implementations§

§

impl Forget for Path

§

impl Freeze for Path
where *const u8 is !null: Freeze, PhantomData<Seg>: Freeze,

§

impl Move for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path
where RawVecInner: Send,

§

impl Sync for Path
where RawVecInner: Sync,

§

impl Unpin for Path
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Path

§

impl UnwindSafe for Path
where RawVecInner: UnwindSafe,

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> ErasedDestructor for T
where T: 'static,

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.