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
impl Path
Sourcepub fn quad_to(self, control: Point, to: Point) -> Path
pub fn quad_to(self, control: Point, to: Point) -> Path
Adds a quadratic curve to to, bent toward control.
Sourcepub fn cubic_to(self, first: Point, second: Point, to: Point) -> Path
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.
Sourcepub fn arc(self, center: Point, radius: f32, start: f32, sweep: f32) -> Path
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.
Sourcepub fn rounded_rect(rect: Rect, radius: f32) -> Path
pub fn rounded_rect(rect: Rect, radius: f32) -> Path
A rectangle with circular corners of radius, at most half its
shorter side.
Sourcepub fn ellipse(center: Point, radius_x: f32, radius_y: f32) -> Path
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.
Sourcepub fn commands(&self) -> &[PathCommand]
pub fn commands(&self) -> &[PathCommand]
The steps, in order.