pub enum DrawCommand {
FillRect {
position: Vector2D,
width: f64,
height: f64,
color: Color,
},
StrokeRect {
position: Vector2D,
width: f64,
height: f64,
color: Color,
line_width: f64,
},
FillCircle {
center: Vector2D,
radius: f64,
color: Color,
},
StrokeCircle {
center: Vector2D,
radius: f64,
color: Color,
line_width: f64,
},
Line {
start: Vector2D,
end: Vector2D,
color: Color,
line_width: f64,
},
FillText {
text: String,
position: Vector2D,
color: Color,
font: String,
},
DrawSprite {
image: HtmlImageElement,
source: Rect,
transform: Transform2D,
},
DrawImageRect {
image: HtmlImageElement,
source: Rect,
dest_position: Vector2D,
dest_width: f64,
dest_height: f64,
},
SetGlobalAlpha {
alpha: f64,
},
SetBlendMode {
mode: BlendMode,
},
}Expand description
A single deferred draw operation recorded into a DrawList.
Commands carry the resolved style for the operation (fill/stroke color, line
width) so that replay can group consecutive same-style shapes into a single
path and skip redundant canvas state changes. Colors are stored as Color
and converted to CSS strings only at replay time.
Variants§
FillRect
Fills a rectangle. Carries the fill color.
Fields
StrokeRect
Strokes the outline of a rectangle. Carries stroke color and line width.
Fields
FillCircle
Fills a circle. Carries the fill color.
Fields
StrokeCircle
Strokes the outline of a circle. Carries stroke color and line width.
Fields
Line
Draws a line segment. Carries stroke color and line width.
Fields
FillText
Fills text at a position. Carries the fill color and font.
Fields
DrawSprite
Draws a transformed sprite sub-region (image, source rect, TRS transform).
Fields
image: HtmlImageElementThe image to draw.
transform: Transform2DThe world-space transform (position, rotation, scale). Scale signs flip.
DrawImageRect
Draws an image sub-region at a destination rect (no rotation).
Fields
image: HtmlImageElementThe image to draw.
SetGlobalAlpha
Applies a global alpha to all subsequent commands until changed.
SetBlendMode
Applies a blend mode to all subsequent commands until changed.
Trait Implementations§
Source§impl Clone for DrawCommand
impl Clone for DrawCommand
Source§fn clone(&self) -> DrawCommand
fn clone(&self) -> DrawCommand
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more