pub struct Canvas<'a> { /* private fields */ }Expand description
A bounded command recorder passed to content.
The first failure poisons the recording, even when a callback ignores the returned error. Geometry is checked and budget charged before storage grows.
Implementations§
Source§impl<'a> Canvas<'a>
impl<'a> Canvas<'a>
Sourcepub fn instances(
&mut self,
batch: Arc<dyn InstanceBatch>,
transform: Transform,
) -> Result<(), ValidationError>
pub fn instances( &mut self, batch: Arc<dyn InstanceBatch>, transform: Transform, ) -> Result<(), ValidationError>
Records evaluated instances without expanding them into path geometry.
Sourcepub fn fill_path(
&mut self,
geometry: Arc<Path2D>,
transform: Transform,
paint: impl Into<Paint>,
rule: FillRule,
) -> Result<(), ValidationError>
pub fn fill_path( &mut self, geometry: Arc<Path2D>, transform: Transform, paint: impl Into<Paint>, rule: FillRule, ) -> Result<(), ValidationError>
Records a shared font-unit/path with its local transform.
Sourcepub fn new(state: &'a mut ValidationState, path: &'a str, depth: usize) -> Self
pub fn new(state: &'a mut ValidationState, path: &'a str, depth: usize) -> Self
Creates a local recorder borrowing the caller’s structural budget and diagnostic path.
Commands and path verbs are charged at depth before they enter the result.
Sourcepub fn fill_rect(
&mut self,
bounds: Rect,
paint: impl Into<Paint>,
) -> Result<(), ValidationError>
pub fn fill_rect( &mut self, bounds: Rect, paint: impl Into<Paint>, ) -> Result<(), ValidationError>
Records a filled rectangle without narrowing geometry or color.
Sourcepub fn fill(
&mut self,
shape: &impl Shape,
paint: impl Into<Paint>,
rule: FillRule,
) -> Result<(), ValidationError>
pub fn fill( &mut self, shape: &impl Shape, paint: impl Into<Paint>, rule: FillRule, ) -> Result<(), ValidationError>
Fills geometry, retaining its explicit contour rule.
Each path verb also consumes one shared work-budget unit at command depth. Rectangles retain the existing constant-cost fill fast path.
Sourcepub fn stroke(
&mut self,
shape: &impl Shape,
style: &StrokeStyle,
paint: impl Into<Paint>,
) -> Result<(), ValidationError>
pub fn stroke( &mut self, shape: &impl Shape, style: &StrokeStyle, paint: impl Into<Paint>, ) -> Result<(), ValidationError>
Expands a bounded line/curve stroke into a NonZero fill.
Source verbs and generated outline verbs charge the shared structural budget independently. Invalid parameters are checked even at zero width. Errors poison the recording even if the caller ignores the Result.
Sourcepub fn record(
self,
drawable: &dyn Drawable,
context: &DrawContext,
) -> Result<Vec<DrawCommand>, ValidationError>
pub fn record( self, drawable: &dyn Drawable, context: &DrawContext, ) -> Result<Vec<DrawCommand>, ValidationError>
Invokes one drawable and returns its complete validated command sequence. The first recorder failure wins even when ignored by the callback; no partial commands escape on error. Callback panics propagate to the caller.