pub enum Shape {
Rect(Rect),
RoundedRect(Rect, f64),
Ellipse(Rect),
Arc {
rect: Rect,
start_deg: f64,
sweep_deg: f64,
},
Line(Point, Point),
Polygon(Vec<Point>),
Path(Path),
}Variants§
Rect(Rect)
RoundedRect(Rect, f64)
Ellipse(Rect)
Arc
Arc within rect’s inscribed ellipse; angles in degrees, 0 = +x axis, clockwise.
Line(Point, Point)
Polygon(Vec<Point>)
Path(Path)
An arbitrary path: curves, several contours, and a fill rule (docs/canvas.md).
Shape::Polygon is the straight-line, single-contour special case, kept because it is
what most drawing code wants and it encodes far more compactly.
Implementations§
Source§impl Shape
impl Shape
Sourcepub fn rounded_rect(rect: Rect, radii: CornerRadii) -> Shape
pub fn rounded_rect(rect: Rect, radii: CornerRadii) -> Shape
A rectangle rounded corner by corner (docs/canvas.md “Rounded corners”), as the simplest
shape that draws it: a plain Shape::Rect when every corner is square, a
Shape::RoundedRect (each toolkit’s own rounded rectangle) when the corners agree, and a
path (rounded_rect_segs) otherwise. The radii are fitted first.
use day_spec::{CornerRadii, Rect, Shape};
// A bar standing on its axis: rounded on top, square where it meets the baseline.
let bar = Shape::rounded_rect(Rect::new(0.0, 0.0, 20.0, 80.0), CornerRadii::top(6.0));
assert!(matches!(bar, Shape::Path(_)));Sourcepub fn translated(&self, dx: f64, dy: f64) -> Shape
pub fn translated(&self, dx: f64, dy: f64) -> Shape
The same shape moved by (dx, dy).
What a Stamp means by “the template translated by one point”, and the one definition of
it: a backend builds each copy of a batch with this rather than reaching for its own
platform transform, so every toolkit stamps to the same coordinates.