pub enum DrawOp {
Fill(Shape, Paint),
Stroke(Shape, Paint, StrokeStyle),
Text {
text: String,
at: Point,
size: f64,
color: Color,
anchor: TextAnchor,
font: CanvasFont,
},
Stamp(Box<Stamp>),
Image {
image: BitmapId,
rect: Rect,
opacity: f64,
},
Clip(Shape),
Save,
Restore,
Concat(Affine),
}Variants§
Fill(Shape, Paint)
Stroke(Shape, Paint, StrokeStyle)
Stroke shape. The paint may be a gradient, and StrokeStyle carries width, dash, cap
and join; Draw::stroke builds the plain width-only case.
Text
One line of text. size is absolute canvas points (no accessibility scale: canvas
text is a label inside a drawing, docs/canvas.md); font picks the family, weight and
slant, and its default is the platform’s own UI face.
Stamp(Box<Stamp>)
Draw one shape at many positions, the batched form of DrawOp::Fill/DrawOp::Stroke
(docs/canvas.md “Stamping”).
Boxed because the payload is wider than the largest other op, and a bigger DrawOp would
cost every op in every drawing, the exact thing this variant exists to stop paying.
Image
Draw an image into rect (docs/images.md).
The source is a BitmapId and never bytes: a canvas re-records on every tracked read,
so carrying a buffer here would hand the backend a megabyte to compare, and re-decode, on
every frame. The app decodes once with day::decode_image and draws the handle.
opacity multiplies the image’s own alpha. A backend that cannot draw a bitmap at all
draws nothing rather than a placeholder rectangle, the same way an unknown op is skipped.
Clip(Shape)
Intersect the clip with shape; everything drawn afterwards is confined to it.
Scoped by DrawOp::Save/DrawOp::Restore, which is the only way to widen a clip
again; every native 2-D context works this way, so there is no “unclip”.
Save
Push the current transform + clip (§11, shapes). Backends map to save/restore of the
native 2-D context; Concat multiplies an affine onto the CTM (shape rotate/scale/offset).
Restore
Concat(Affine)
Trait Implementations§
impl StructuralPartialEq for DrawOp
Auto Trait Implementations§
impl Freeze for DrawOp
impl RefUnwindSafe for DrawOp
impl Send for DrawOp
impl Sync for DrawOp
impl Unpin for DrawOp
impl UnsafeUnpin for DrawOp
impl UnwindSafe for DrawOp
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