Skip to main content

DrawCommand

Enum DrawCommand 

Source
pub enum DrawCommand {
Show 15 variants 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, }, BackdropBlur { rect: Rect, radius: CornerRadius, blur_radius: f32, }, TextRun { rect: Rect, text: String, style: TextStyle, }, TextCaret { text_rect: Rect, content_rect: Rect, text: String, style: TextStyle, caret_height: f32, color: Color, multiline: bool, }, 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), PushRoundedClip { rect: Rect, radius: CornerRadius, }, 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.

§

BackdropBlur

Applies a backdrop blur sampling the previously rendered pixels beneath rect.

Fields

§rect: Rect

Output bounds in logical pixels.

§radius: CornerRadius

Corner radii mask in logical pixels.

§blur_radius: f32

Gaussian blur radius in logical pixels.

§

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.

§

TextCaret

Draws a blinking text-input caret aligned to exact rasterized glyph advances.

Fields

§text_rect: Rect

Text layout bounding rectangle in logical pixels.

§content_rect: Rect

Input inner content clip rectangle in logical pixels.

§text: String

Active input text preceding the caret.

§style: TextStyle

Typography style matching the input’s TextRun.

§caret_height: f32

Caret height in logical pixels.

§color: Color

Caret fill color.

§multiline: bool

Whether the input wraps across multiple lines.

§

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.

§

PushRoundedClip

Pushes a rounded-rectangle clip mask onto the clip stack, balanced by PopClip.

Fields

§rect: Rect

Clip rectangle bounds in logical pixels.

§radius: CornerRadius

Corner radii in logical pixels.

§

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§

§

impl Forget for DrawCommand

§

impl Freeze for DrawCommand
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for DrawCommand

§

impl RefUnwindSafe for DrawCommand

§

impl Send for DrawCommand
where RawVecInner: Send,

§

impl Sync for DrawCommand
where RawVecInner: Sync,

§

impl Unpin for DrawCommand
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for DrawCommand

§

impl UnwindSafe for DrawCommand
where RawVecInner: UnwindSafe,

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.