Skip to main content

Canvas

Struct Canvas 

Source
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>

Source

pub fn instances( &mut self, batch: Arc<dyn InstanceBatch>, transform: Transform, ) -> Result<(), ValidationError>

Records evaluated instances without expanding them into path geometry.

Source

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.

Source

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.

Source

pub fn fill_rect( &mut self, bounds: Rect, paint: impl Into<Paint>, ) -> Result<(), ValidationError>

Records a filled rectangle without narrowing geometry or color.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Canvas<'a>

§

impl<'a> !UnwindSafe for Canvas<'a>

§

impl<'a> Forget for Canvas<'a>

§

impl<'a> Freeze for Canvas<'a>

§

impl<'a> Send for Canvas<'a>

§

impl<'a> Sync for Canvas<'a>

§

impl<'a> Unpin for Canvas<'a>

§

impl<'a> UnsafeUnpin for Canvas<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.