pub struct DrawList { /* private fields */ }Expand description
An ordered buffer of deferred draw commands recorded during a frame.
Scenes and components push DrawCommands into the list during on_render
instead of drawing immediately. The engine then replays the whole list once
per frame via CanvasRenderer::replay, which batches consecutive same-style
shapes into a single path and skips redundant canvas state changes. The
backing Vec is reused across frames via clear() to avoid reallocation.
Implementations§
Source§impl DrawList
Implements drawing and camera management methods for CanvasRenderer.
Implements recording and replay for DrawList.
impl DrawList
Implements drawing and camera management methods for CanvasRenderer.
Implements recording and replay for DrawList.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the list contains no commands.
§Returns
bool-trueif there are no recorded commands.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes all recorded commands, keeping the allocated capacity for reuse on the next frame.
Sourcepub fn fill_rect(
&mut self,
position: Vector2D,
width: f64,
height: f64,
color: Color,
)
pub fn fill_rect( &mut self, position: Vector2D, width: f64, height: f64, color: Color, )
Records a fill-rectangle command.
Sourcepub fn stroke_rect(
&mut self,
position: Vector2D,
width: f64,
height: f64,
color: Color,
line_width: f64,
)
pub fn stroke_rect( &mut self, position: Vector2D, width: f64, height: f64, color: Color, line_width: f64, )
Records a stroke-rectangle command.
Sourcepub fn fill_circle(&mut self, center: Vector2D, radius: f64, color: Color)
pub fn fill_circle(&mut self, center: Vector2D, radius: f64, color: Color)
Records a fill-circle command.
Sourcepub fn stroke_circle(
&mut self,
center: Vector2D,
radius: f64,
color: Color,
line_width: f64,
)
pub fn stroke_circle( &mut self, center: Vector2D, radius: f64, color: Color, line_width: f64, )
Records a stroke-circle command.
Sourcepub fn draw_line(
&mut self,
start: Vector2D,
end: Vector2D,
color: Color,
line_width: f64,
)
pub fn draw_line( &mut self, start: Vector2D, end: Vector2D, color: Color, line_width: f64, )
Records a line-segment command.
Sourcepub fn fill_text<T, F>(
&mut self,
text: T,
position: Vector2D,
color: Color,
font: F,
)
pub fn fill_text<T, F>( &mut self, text: T, position: Vector2D, color: Color, font: F, )
Records a fill-text command.
Sourcepub fn draw_sprite(
&mut self,
image: &HtmlImageElement,
source: Rect,
transform: Transform2D,
)
pub fn draw_sprite( &mut self, image: &HtmlImageElement, source: Rect, transform: Transform2D, )
Records a transformed sprite draw command.
Sourcepub fn draw_image_rect(
&mut self,
image: &HtmlImageElement,
source: Rect,
dest_position: Vector2D,
dest_width: f64,
dest_height: f64,
)
pub fn draw_image_rect( &mut self, image: &HtmlImageElement, source: Rect, dest_position: Vector2D, dest_width: f64, dest_height: f64, )
Records an image sub-region draw command (no rotation).
Sourcepub fn set_global_alpha(&mut self, alpha: f64)
pub fn set_global_alpha(&mut self, alpha: f64)
Records a global-alpha state change.
Sourcepub fn set_blend_mode(&mut self, mode: BlendMode)
pub fn set_blend_mode(&mut self, mode: BlendMode)
Records a blend-mode state change.