Skip to main content

Path

Struct Path 

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

A shape to fill or stroke on a Canvas, built from lines, curves and arcs in logical pixels from the canvas’s top-left corner. It is plain data, so it can be built once outside the paint closure.

use crabshell_ui::{Path, Point, Rect};

let tick = Path::new()
    .move_to(Point::new(2.0, 8.0))
    .line_to(Point::new(6.0, 12.0))
    .line_to(Point::new(14.0, 4.0));
// A quarter of a ring from 12 o'clock, as a progress ring at 25%.
let progress = Path::new().arc(Point::new(20.0, 20.0), 16.0, -90.0, 90.0);
let card = Path::rounded_rect(Rect::new(0.0, 0.0, 40.0, 40.0), 8.0);

Implementations§

Source§

impl Path

Source

pub fn new() -> Path

An empty path.

Source

pub fn move_to(self, to: Point) -> Path

Starts a new piece at to.

Source

pub fn line_to(self, to: Point) -> Path

Adds a straight line to to.

Source

pub fn quad_to(self, control: Point, to: Point) -> Path

Adds a quadratic curve to to, bent toward control.

Source

pub fn cubic_to(self, first: Point, second: Point, to: Point) -> Path

Adds a cubic curve to to, leaving toward first and arriving from second.

Source

pub fn arc(self, center: Point, radius: f32, start: f32, sweep: f32) -> Path

Adds an arc of the circle around center, from start degrees through sweep degrees, clockwise from 3 o’clock, as an HTML canvas’s arc goes: a negative sweep runs counterclockwise, and a sweep past a whole turn is one. A line joins it to where the path was; on an empty path it starts a piece.

Source

pub fn close(self) -> Path

Closes the piece with a straight line back to its start.

Source

pub fn rect(rect: Rect) -> Path

A rectangle.

Source

pub fn rounded_rect(rect: Rect, radius: f32) -> Path

A rectangle with circular corners of radius, at most half its shorter side.

Source

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

A circle around center.

Source

pub fn ellipse(center: Point, radius_x: f32, radius_y: f32) -> Path

An ellipse around center, radius_x wide and radius_y tall on each side.

Source

pub fn commands(&self) -> &[PathCommand]

The steps, in order.

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

§

impl Move for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnsafeUnpin for Path

§

impl UnwindSafe for Path

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more