Skip to main content

DrawCommand

Enum DrawCommand 

Source
pub enum DrawCommand {
    Clear(Color),
    FillRoundedRect {
        rect: Rect,
        color: Color,
        radius: CornerRadius,
        border: Border,
    },
    LinearGradientRect {
        rect: Rect,
        gradient: LinearGradient,
        radius: CornerRadius,
    },
    BoxShadow {
        rect: Rect,
        radius: CornerRadius,
        shadow: Shadow,
    },
    TextRun {
        rect: Rect,
        text: String,
        style: TextStyle,
    },
    Image {
        rect: Rect,
        buffer: ImageBuffer,
        radius: CornerRadius,
    },
    Line {
        from: Point,
        to: Point,
        color: Color,
        width: f32,
    },
    Circle {
        center: Point,
        radius: f32,
        color: Color,
    },
    Triangle {
        p0: Point,
        p1: Point,
        p2: Point,
        color: Color,
    },
    SpriteRegion {
        rect: Rect,
        buffer: ImageBuffer,
        src_rect: Rect,
        tint: Color,
    },
    PushClip(Rect),
    PopClip,
}
Expand description

Backend-agnostic vector/UI drawing primitive emitted by PaintPass and consumed by all renderers.

Variants§

§

Clear(Color)

Clears the target surface to Color.

§

FillRoundedRect

Draws a rounded or sharp filled rectangle with optional border stroke.

Fields

§rect: Rect

Bounds in logical pixels.

§color: Color

Fill color.

§radius: CornerRadius

Corner radii.

§border: Border

Optional border stroke.

§

LinearGradientRect

Draws a two-stop linear gradient inside a rounded rectangle.

Fields

§rect: Rect

Bounds in logical pixels.

§gradient: LinearGradient

Gradient specification.

§radius: CornerRadius

Corner radii.

§

BoxShadow

Draws a soft drop shadow under a rounded rectangle.

Fields

§rect: Rect

Casting box bounds.

§radius: CornerRadius

Corner radii.

§shadow: Shadow

Shadow parameters.

§

TextRun

Draws a laid-out text run using the shared deterministic glyph atlas.

Fields

§rect: Rect

Bounding rectangle in logical pixels.

§text: String

UTF-8 text string.

§style: TextStyle

Typography style.

§

Image

Blits a decoded RGBA8 image buffer into rect.

Fields

§rect: Rect

Destination bounds.

§buffer: ImageBuffer

Image pixel buffer.

§radius: CornerRadius

Corner radii mask.

§

Line

Draws a straight anti-aliased line segment (used by custom canvases and dividers).

Fields

§from: Point

Start point.

§to: Point

End point.

§color: Color

Line color.

§width: f32

Stroke width.

§

Circle

Draws a filled anti-aliased circle (used by badges, avatars, spinners, and custom canvases).

Fields

§center: Point

Center point.

§radius: f32

Circle radius.

§color: Color

Fill color.

§

Triangle

Draws a filled triangle primitive (used by 2D game meshes, spaceships, lasers, and polygons).

Fields

§p0: Point

First vertex in logical pixels.

§p1: Point

Second vertex in logical pixels.

§p2: Point

Third vertex in logical pixels.

§color: Color

Fill color.

§

SpriteRegion

Blits a cropped sub-region of an ImageBuffer sprite sheet with optional tint color.

Fields

§rect: Rect

Destination bounds in logical pixels.

§buffer: ImageBuffer

Source sprite-sheet RGBA8 buffer.

§src_rect: Rect

Source pixel sub-rectangle (x, y, w, h).

§tint: Color

Multiplicative tint color (COLOR_WHITE for untinted).

§

PushClip(Rect)

Pushes an axis-aligned clip rectangle onto the clip stack.

§

PopClip

Pops the top clip rectangle from the clip stack.

Trait Implementations§

Source§

impl Clone for DrawCommand

Source§

fn clone(&self) -> Self

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 DrawCommand

Source§

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

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

impl PartialEq for DrawCommand

Source§

fn eq(&self, other: &Self) -> 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 DrawCommand

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.