Skip to main content

CanvasCtx

Struct CanvasCtx 

Source
pub struct CanvasCtx<'a> {
    pub did_layout: bool,
    pub is_active: bool,
    pub is_enabled: bool,
    pub is_focused: bool,
    pub perf_info: &'a PerfInfo,
    pub rect: &'a RoundedRect,
    pub scene: &'a mut Scene,
    pub style: &'a Style,
    pub translation_map: TranslationMap,
}
Expand description

A context provided to the on_canvas callback of a node for rendering.

CanvasCtx provides access to the Vello Scene for issuing graphics commands in local space, as well as the node’s layout information, computed styles, and interaction state (active/focused).

Fields§

§did_layout: bool§is_active: bool§is_enabled: bool§is_focused: bool§perf_info: &'a PerfInfo§rect: &'a RoundedRect§scene: &'a mut Scene§style: &'a Style§translation_map: TranslationMap

Implementations§

Source§

impl<'a> CanvasCtx<'a>

Source

pub fn padding_box(&self) -> Rect

Returns the rect just inside the borders of the node in local space. Doesn’t account for rounded corners.

Source

pub fn max_content_width(&self) -> f32

Returns the maximum width content could be before overflowing node.

Source

pub fn draw_text(&mut self, text: &str)

Draw text according to this node’s CSS styles.

Source

pub fn draw_text_at_origin( &mut self, origin: Point, max_width: impl Into<Option<f32>>, text: &str, )

Draw text at the provided location according to this node’s CSS styles.

Source

pub fn draw_text_layout(&mut self, origin: Point, layout: &Layout<[u8; 4]>)

Draws a text layout at the specified location.

Auto Trait Implementations§

§

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

§

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

§

impl<'a> Freeze for CanvasCtx<'a>

§

impl<'a> Send for CanvasCtx<'a>

§

impl<'a> Sync for CanvasCtx<'a>

§

impl<'a> Unpin for CanvasCtx<'a>

§

impl<'a> UnsafeUnpin for CanvasCtx<'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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,