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 commands(&self) -> &[DrawCommand]
pub fn commands(&self) -> &[DrawCommand]
Returns the recorded commands as a slice for replay iteration.
§Returns
&[DrawCommand]- The commands in the order they were recorded.
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.
§Arguments
Vector2D- 2D vector (Vector2D).f64- A 64-bit float (f64).f64- A 64-bit float (f64).Color- AColorparameter.
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.
§Arguments
Vector2D- 2D vector (Vector2D).f64- A 64-bit float (f64).f64- A 64-bit float (f64).Color- AColorparameter.f64- A 64-bit float (f64).
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.
§Arguments
Vector2D- 2D vector (Vector2D).f64- A 64-bit float (f64).Color- AColorparameter.
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.
§Arguments
Vector2D- 2D vector (Vector2D).f64- A 64-bit float (f64).Color- AColorparameter.f64- A 64-bit float (f64).
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.
§Arguments
Vector2D- 2D vector (Vector2D).Vector2D- 2D vector (Vector2D).Color- AColorparameter.f64- A 64-bit float (f64).
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.
§Arguments
T: AsRef<str>- A generic type parameter.Vector2D- 2D vector (Vector2D).Color- AColorparameter.F: AsRef<str>- A generic type parameter.
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.
§Arguments
&HtmlImageElement- Shared reference to aHtmlImageElement.Rect- ARectparameter.Transform2D- ATransform2Dparameter.
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).
§Arguments
&HtmlImageElement- Shared reference to aHtmlImageElement.Rect- ARectparameter.Vector2D- 2D vector (Vector2D).f64- A 64-bit float (f64).f64- A 64-bit float (f64).