Skip to main content

DrawCommand

Enum DrawCommand 

Source
pub enum DrawCommand {
Show 14 variants FillRect { rect: Rect, color: Color, }, StrokeRect { rect: Rect, color: Color, width: f32, }, FillRRect { rect: Rect, radius: f32, color: Color, }, StrokeRRect { rect: Rect, radius: f32, color: Color, width: f32, }, FillCircle { center: Point, radius: f32, color: Color, }, FillGradient { rect: Rect, radius: f32, from: Color, to: Color, vertical: bool, }, FillArc { center: Point, radius: f32, thickness: f32, start_deg: f32, sweep_deg: f32, color: Color, }, DrawText { text: String, origin: Point, color: Color, px: f32, weight: FontWeight, }, DrawShadow { rect: Rect, radius: f32, color: Color, blur: f32, }, BlitRgba { pixels: Arc<Vec<u8>>, src_width: u32, src_height: u32, dest_rect: Rect, opacity: f32, }, PushClip { rect: Rect, }, PopClip, BackdropBlur { rect: Rect, radius: f32, blur: f32, tint: Color, }, ShaderFill { pipeline_id: u64, rect: Rect, uniforms: Vec<u8>, animate_time: bool, },
}
Expand description

A single drawing instruction recorded during the paint pass.

Widgets push these into a [PictureRecorder] instead of writing pixels directly. The compositor later replays them onto whatever backend is active (currently [SkiaCanvas], eventually wgpu).

Variants§

§

FillRect

Fields

§rect: Rect
§color: Color
§

StrokeRect

Fields

§rect: Rect
§color: Color
§width: f32
§

FillRRect

Filled rounded rectangle — a single anti-aliased path.

Fields

§rect: Rect
§radius: f32
§color: Color
§

StrokeRRect

Rounded rectangle outline — matches the FillRRect geometry so borders hug rounded fills instead of framing them with square corners.

Fields

§rect: Rect
§radius: f32
§color: Color
§width: f32
§

FillCircle

Fields

§center: Point
§radius: f32
§color: Color
§

FillGradient

Two-stop linear gradient fill of a (rounded) rect. vertical picks the axis; radius rounds corners (0 = square).

Fields

§rect: Rect
§radius: f32
§from: Color
§vertical: bool
§

FillArc

A ring segment: stroke of thickness thickness along the circle of radius centered at center, from start_deg sweeping sweep_deg clockwise (0° = 3 o’clock). Powers progress rings and spinners.

Fields

§center: Point
§radius: f32
§thickness: f32
§start_deg: f32
§sweep_deg: f32
§color: Color
§

DrawText

Fields

§text: String
§origin: Point
§color: Color
§px: f32
§weight: FontWeight
§

DrawShadow

Gaussian-approximate drop shadow. radius rounds the shadow’s source shape to match rounded widgets — a square shadow behind a rounded fill leaks dark corner triangles.

Fields

§rect: Rect
§radius: f32
§color: Color
§blur: f32
§

BlitRgba

Raw pre-decoded RGBA pixel blit. pixels must be width × height × 4 bytes. opacity (0.0-1.0) scales the blit’s alpha — D108/Phase 26 Step 4’s image load-in fade; 1.0 is the previous, fully-opaque behavior.

Fields

§pixels: Arc<Vec<u8>>
§src_width: u32
§src_height: u32
§dest_rect: Rect
§opacity: f32
§

PushClip

Push a clip rect — subsequent commands are confined to rect (intersected with any already-active clip). Must be paired with DrawCommand::PopClip.

Fields

§rect: Rect
§

PopClip

Restore the clip rect that was active before the matching DrawCommand::PushClip.

§

BackdropBlur

Frosted-glass panel (D-DEF-012 backdrop blur): everything already drawn beneath rect is blurred and tinted behind a rounded panel. GPU-composited targets only; the CPU fallback renders a translucent tint (no blur) — honest degradation, not silence. blur is the Gaussian strength in logical px; tint’s alpha is the tint mix.

Fields

§rect: Rect
§radius: f32
§blur: f32
§tint: Color
§

ShaderFill

Fill rect with a registered GPU shader pipeline (D109/Phase 27).

pipeline_id is the raw value of a rosace-shader PipelineId (this Layer-4 crate cannot import the Layer-5 typed id). uniforms are WGSL-uniform-layout bytes produced by #[derive(ShaderUniforms)] — opaque here. This command has NO CPU rasterization path by design: SkiaCanvas::play_picture collects it (see take_shader_quads) for the compositor to execute on the GPU at present time.

animate_time (D109 maturity, 2026-07-18): when true, the platform patches the first 4 uniform bytes with a live clock at every present (the standard time-first uniform convention) — continuous shader animation then costs one 16-byte GPU buffer write per frame instead of a full CPU tree repaint. The widget records this command ONCE; no per-frame repaint, no request_animation loop.

Fields

§pipeline_id: u64
§rect: Rect
§uniforms: Vec<u8>
§animate_time: bool

Implementations§

Source§

impl DrawCommand

Source

pub fn offset(&self, dx: f32, dy: f32) -> Self

Return a copy of this command translated by (dx, dy) in logical pixels (D088).

Source

pub fn morph( &self, src_origin: Point, dst_origin: Point, sx: f32, sy: f32, ) -> Self

Return a copy of this command remapped from a src-rect-relative coordinate space to a dst one — translating AND scaling, unlike Self::offset which only translates. Backs Hero/shared-element transitions (D108/Phase 26 Step 5): a captured crate::Picture recorded at a widget’s rect on one screen is replayed at a different-sized rect on the other screen’s tag match, morphing between the two. Non-rect geometry (circle/arc radius, stroke/blur width, font size) has no independent x/y scale of its own, so it scales uniformly by the average of sx/sy.

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

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.