Skip to main content

DrawCommand

Enum DrawCommand 

Source
#[non_exhaustive]
pub enum DrawCommand {
Show 20 variants PushClip { rect: Rect, }, PopClip, FillRect { rect: Rect, color: Color, }, StrokeRect { rect: Rect, thickness: f32, color: Color, }, FillRoundedRect { rect: Rect, radius: f32, color: Color, }, FillRoundedRectPerCorner { rect: Rect, radii: [f32; 4], color: Color, }, FillCircle { center: Point, radius: f32, color: Color, }, FillEllipse { center: Point, rx: f32, ry: f32, color: Color, }, Line { from: Point, to: Point, color: Color, }, LineAa { from: Point, to: Point, color: Color, }, LineThick { from: Point, to: Point, width: f32, color: Color, }, LineDashed { from: Point, to: Point, dash_len: f32, gap_len: f32, color: Color, }, FillPath { path: PathData, color: Color, }, StrokePath { path: PathData, style: StrokeStyle, color: Color, }, LinearGradient { rect: Rect, start: Point, end: Point, stops: Vec<GradientStop>, }, RadialGradient { rect: Rect, center: Point, radius: f32, stops: Vec<GradientStop>, }, Image { image: ImageData, dest: Rect, filter: ImageFilter, }, NineSlice { image: ImageData, dest: Rect, insets: [u32; 4], }, BoxShadow { rect: Rect, offset: Point, blur_radius: f32, color: Color, }, DrawText { rect: Rect, text: String, font: FontSpec, color: Color, },
}
Expand description

A single, backend-agnostic draw operation.

Commands are stored in a DrawList and later replayed by a RenderBackend. The enum is #[non_exhaustive] so that new variants can be added without breaking downstream code.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

PushClip

Push a rectangular clip region onto the clip stack.

All subsequent commands are clipped to the intersection of active clip rectangles until the matching DrawCommand::PopClip.

Fields

§rect: Rect

The clip rectangle in logical pixels.

§

PopClip

Pop the most recently pushed clip rectangle from the clip stack.

§

FillRect

Fill an axis-aligned rectangle with a solid colour.

Fields

§rect: Rect

The rectangle to fill.

§color: Color

Fill colour.

§

StrokeRect

Stroke the outline of an axis-aligned rectangle.

Fields

§rect: Rect

The rectangle to stroke.

§thickness: f32

Stroke width in logical pixels.

§color: Color

Stroke colour.

§

FillRoundedRect

Fill a rectangle with uniformly rounded corners.

Fields

§rect: Rect

The rectangle to fill.

§radius: f32

Corner radius in logical pixels (applied to all four corners).

§color: Color

Fill colour.

§

FillRoundedRectPerCorner

Fill a rectangle with per-corner radii.

radii is [top-left, top-right, bottom-right, bottom-left].

Fields

§rect: Rect

The rectangle to fill.

§radii: [f32; 4]

Per-corner radii [tl, tr, br, bl] in logical pixels.

§color: Color

Fill colour.

§

FillCircle

Fill a circle with a solid colour.

Fields

§center: Point

Centre point of the circle.

§radius: f32

Radius in logical pixels.

§color: Color

Fill colour.

§

FillEllipse

Fill an ellipse with a solid colour.

Fields

§center: Point

Centre point of the ellipse.

§rx: f32

Horizontal (X-axis) radius in logical pixels.

§ry: f32

Vertical (Y-axis) radius in logical pixels.

§color: Color

Fill colour.

§

Line

Draw a 1-pixel aliased line segment.

Fields

§from: Point

Start point of the line.

§to: Point

End point of the line.

§color: Color

Line colour.

§

LineAa

Draw a 1-pixel anti-aliased line segment.

Fields

§from: Point

Start point of the line.

§to: Point

End point of the line.

§color: Color

Line colour.

§

LineThick

Draw a thick, filled line segment.

Fields

§from: Point

Start point of the line.

§to: Point

End point of the line.

§width: f32

Width of the line in logical pixels.

§color: Color

Line colour.

§

LineDashed

Draw a dashed line segment.

Fields

§from: Point

Start point of the line.

§to: Point

End point of the line.

§dash_len: f32

Length of each dash in logical pixels.

§gap_len: f32

Length of each gap in logical pixels.

§color: Color

Line colour.

§

FillPath

Fill a path with a solid colour.

Fields

§path: PathData

The path to fill.

§color: Color

Fill colour.

§

StrokePath

Stroke a path with a solid colour and style.

Fields

§path: PathData

The path to stroke.

§style: StrokeStyle

Stroke parameters (width, join, cap, miter limit).

§color: Color

Stroke colour.

§

LinearGradient

Fill a rectangular region with a linear gradient.

Fields

§rect: Rect

The destination rectangle (defines the fill area).

§start: Point

Start point of the gradient axis.

§end: Point

End point of the gradient axis.

§stops: Vec<GradientStop>

Colour stops defining the ramp.

§

RadialGradient

Fill a rectangular region with a radial gradient.

Fields

§rect: Rect

The destination rectangle (defines the fill area).

§center: Point

Centre of the radial gradient.

§radius: f32

Outer radius of the gradient in logical pixels.

§stops: Vec<GradientStop>

Colour stops defining the ramp.

§

Image

Blit a raw RGBA image into a destination rectangle.

Fields

§image: ImageData

The source image data.

§dest: Rect

Destination rectangle in logical pixels.

§filter: ImageFilter

Resampling filter to use when scaling.

§

NineSlice

Draw an image using 9-slice scaling.

insets is [top, right, bottom, left] in pixels of the source image.

Fields

§image: ImageData

The source image data.

§dest: Rect

Destination rectangle in logical pixels.

§insets: [u32; 4]

9-slice insets [top, right, bottom, left] in source pixels.

§

BoxShadow

Draw a box shadow behind a rectangle.

Fields

§rect: Rect

The rectangle casting the shadow.

§offset: Point

Shadow offset relative to rect.

§blur_radius: f32

Blur radius in logical pixels (0 = hard edge).

§color: Color

Shadow colour (typically semi-transparent).

§

DrawText

Draw text into a rectangle.

Full shaping is delegated to the backend; this command is a v1 placeholder. Backends that do not support text return Err.

Fields

§rect: Rect

Bounding rectangle for the text.

§text: String

The string to render.

§font: FontSpec

Font specification (family, size, weight, style).

§color: Color

Text colour.

Trait Implementations§

Source§

impl Clone for DrawCommand

Source§

fn clone(&self) -> DrawCommand

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: &DrawCommand) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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 = 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.