Skip to main content

DrawOp

Enum DrawOp 

Source
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.

Fields

§text: String
§size: f64
§color: Color
§anchor: TextAnchor
§

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.

Fields

§image: BitmapId
§rect: Rect
§opacity: f64
§

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§

Source§

impl Clone for DrawOp

Source§

fn clone(&self) -> DrawOp

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DrawOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DrawOp

Source§

fn eq(&self, other: &DrawOp) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DrawOp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Day API ↩ Guides· daybrite.dev