Skip to main content

Command

Enum Command 

Source
pub enum Command {
    MoveTo(f32, f32),
    LineTo(f32, f32),
    QuadTo(f32, f32, f32, f32),
    CubicTo(f32, f32, f32, f32, f32, f32),
    Close,
}
Expand description

One resolved path segment, absolute.

Variants§

§

MoveTo(f32, f32)

Start a new subpath at this point.

§

LineTo(f32, f32)

Straight segment to this point.

§

QuadTo(f32, f32, f32, f32)

Quadratic segment: control point, then the on-curve endpoint.

§

CubicTo(f32, f32, f32, f32, f32, f32)

Cubic segment: two control points, then the on-curve endpoint.

§

Close

Close the current subpath. The line back to the subpath start is implicit: the stored command list gains no synthetic LineTo, but Path::area, Path::bbox, and every consumer of a Path account for it.

Implementations§

Source§

impl Command

Source

pub fn end_point(&self) -> Option<(f32, f32)>

The on-curve point this command ends at (None for Command::Close).

Source

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

Command::MoveTo as a standalone command.

Source

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

Command::LineTo as a standalone command.

Source

pub const fn quad_to(cx: f32, cy: f32, x: f32, y: f32) -> Self

Command::QuadTo as a standalone command.

Source

pub const fn cubic_to( c1x: f32, c1y: f32, c2x: f32, c2y: f32, x: f32, y: f32, ) -> Self

Command::CubicTo as a standalone command.

Source

pub const fn close() -> Self

Command::Close as a standalone command.

Source

pub fn relative_to(&self, current: (f32, f32)) -> (u8, [f32; 6])

Rewrite this command as deltas from current, the point the segment starts at: (opcode, [dx, dy, dx2, dy2]).

The model stores absolute commands; this is the relative view a writer emits for delta-encoded contours. The array holds [dx, dy, dx2, dy2, dx3, dy3] — control points and endpoint, each as a delta from current; unused trailing slots are zero. Opcodes: 0 move, 1 line, 2 quad, 3 cubic, 4 close.

Trait Implementations§

Source§

impl Clone for Command

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 Copy for Command

Source§

impl Debug for Command

Source§

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

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

impl PartialEq for Command

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 Command

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.