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.
Trait Implementations§
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnsafeUnpin for Shape
impl UnwindSafe for Shape
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more