pub struct RecordingCanvas { /* private fields */ }Expand description
A Canvas implementation that records draw operations as DrawCommands.
This is useful for:
- Testing (verify what was painted)
- Serialization (send commands to GPU/WASM)
- Diffing (compare render outputs)
Implementations§
Source§impl RecordingCanvas
impl RecordingCanvas
Sourcepub fn new() -> RecordingCanvas
pub fn new() -> RecordingCanvas
Create a new empty recording canvas.
Sourcepub fn commands(&self) -> &[DrawCommand]
pub fn commands(&self) -> &[DrawCommand]
Get the recorded draw commands.
Sourcepub fn take_commands(&mut self) -> Vec<DrawCommand>
pub fn take_commands(&mut self) -> Vec<DrawCommand>
Take ownership of the recorded commands, clearing the canvas.
Sourcepub fn command_count(&self) -> usize
pub fn command_count(&self) -> usize
Get the number of recorded commands.
Sourcepub fn current_transform(&self) -> Transform2D
pub fn current_transform(&self) -> Transform2D
Get the current transform (identity if no transforms pushed).
Sourcepub fn current_clip(&self) -> Option<Rect>
pub fn current_clip(&self) -> Option<Rect>
Get the current clip bounds (None if no clips pushed).
Sourcepub fn clip_depth(&self) -> usize
pub fn clip_depth(&self) -> usize
Get the clip stack depth.
Sourcepub fn transform_depth(&self) -> usize
pub fn transform_depth(&self) -> usize
Get the transform stack depth.
Sourcepub fn add_command(&mut self, command: DrawCommand)
pub fn add_command(&mut self, command: DrawCommand)
Add a raw draw command.
Sourcepub fn fill_circle(&mut self, center: Point, radius: f32, color: Color)
pub fn fill_circle(&mut self, center: Point, radius: f32, color: Color)
Draw a filled circle.
Sourcepub fn draw_line(&mut self, from: Point, to: Point, color: Color, width: f32)
pub fn draw_line(&mut self, from: Point, to: Point, color: Color, width: f32)
Draw a line between two points.
Sourcepub fn draw_path(
&mut self,
points: &[Point],
closed: bool,
color: Color,
width: f32,
)
pub fn draw_path( &mut self, points: &[Point], closed: bool, color: Color, width: f32, )
Draw a path (polyline).
Sourcepub fn fill_rounded_rect(&mut self, rect: Rect, radius: f32, color: Color)
pub fn fill_rounded_rect(&mut self, rect: Rect, radius: f32, color: Color)
Draw a rounded rectangle.
Trait Implementations§
Source§impl Canvas for RecordingCanvas
impl Canvas for RecordingCanvas
Source§fn draw_line(&mut self, from: Point, to: Point, color: Color, width: f32)
fn draw_line(&mut self, from: Point, to: Point, color: Color, width: f32)
Draw a line between two points.
Source§fn stroke_circle(
&mut self,
center: Point,
radius: f32,
color: Color,
width: f32,
)
fn stroke_circle( &mut self, center: Point, radius: f32, color: Color, width: f32, )
Draw a stroked circle.
Source§fn fill_arc(
&mut self,
center: Point,
radius: f32,
start_angle: f32,
end_angle: f32,
color: Color,
)
fn fill_arc( &mut self, center: Point, radius: f32, start_angle: f32, end_angle: f32, color: Color, )
Draw a filled arc (pie slice).
Source§fn fill_polygon(&mut self, points: &[Point], color: Color)
fn fill_polygon(&mut self, points: &[Point], color: Color)
Fill a polygon.
Source§fn push_transform(&mut self, transform: Transform2D)
fn push_transform(&mut self, transform: Transform2D)
Push a transform.
Source§fn pop_transform(&mut self)
fn pop_transform(&mut self)
Pop the transform.
Source§impl Debug for RecordingCanvas
impl Debug for RecordingCanvas
Source§impl Default for RecordingCanvas
impl Default for RecordingCanvas
Source§fn default() -> RecordingCanvas
fn default() -> RecordingCanvas
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RecordingCanvas
impl RefUnwindSafe for RecordingCanvas
impl Send for RecordingCanvas
impl Sync for RecordingCanvas
impl Unpin for RecordingCanvas
impl UnwindSafe for RecordingCanvas
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more