enum
Shape
pub enum Shape {
Rect { x: f32, y: f32, w: f32, h: f32, r: f32, style: Style },
Circle { cx: f32, cy: f32, r: f32, style: Style },
Line { x1: f32, y1: f32, x2: f32, y2: f32, style: Style },
Polyline { points: Vec<(f32, f32)>, closed: bool, smooth: bool, style: Style },
Arc { cx: f32, cy: f32, r: f32, inner: f32, start: f32, end: f32, style: Style },
Text { x: f32, y: f32, text: String, size: f32, align: TextAlign, weight: u16, style: Style },
}A shape on a 2D canvas.
Variants
Polyline
Polyline { points: Vec<(f32, f32)>, closed: bool, smooth: bool, style: Style }smooth draws a Catmull-Rom curve through the points.
Arc
Arc { cx: f32, cy: f32, r: f32, inner: f32, start: f32, end: f32, style: Style }A ring segment (pie slice when inner is 0). Angles are degrees, clockwise from 12 o'clock.
Text
Text { x: f32, y: f32, text: String, size: f32, align: TextAlign, weight: u16, style: Style }y is the text baseline.
Methods
rounded_rect
pub fn rounded_rect(x: f32, y: f32, w: f32, h: f32, r: f32, style: Style) -> ShapeA rectangle with corners of radius r.
line
pub fn line(x1: f32, y1: f32, x2: f32, y2: f32, style: Style) -> ShapeA line from x1, y1 to x2, y2.
arc
pub fn arc(cx: f32, cy: f32, r: f32, inner: f32, start: f32, end: f32, style: Style) -> ShapeAn arc from angle start to end (radians), inner radius 0 for a pie slice, more for a ring.
text
pub fn text(x: f32, y: f32, text: &str, size: f32, style: Style) -> ShapeText at x, y, size pixels high.
contains
pub fn contains(&self, x: f32, y: f32) -> boolPrecise hit test (lines get a small tolerance so they're clickable).