Skip to main content

CanvasContext

Struct CanvasContext 

Source
pub struct CanvasContext { /* private fields */ }
Expand description

Frame-scoped command recorder passed to super::CanvasItem::draw.

Implementations§

Source§

impl CanvasContext

Source

pub const fn size(&self) -> Size

Source

pub const fn bounds(&self) -> (Position, Size)

Source

pub fn view( &mut self, origin: Position, view: View, width: Option<usize>, height: Option<usize>, )

Records a View using Composition::Replace.

Supply a finite allocation on every axis whose result depends on crate::Length::Fill. Canvas bounds are not an implicit allocation.

Source

pub fn view_with( &mut self, origin: Position, view: View, width: Option<usize>, height: Option<usize>, composition: Composition, )

Records a View with an explicit composition rule.

Allocation requirements are the same as for Self::view.

Source

pub fn text( &mut self, origin: Position, text: impl Into<String>, style: TextStyle, )

Records plain text using Composition::Overlay.

As with View::text, text must not contain terminal controls.

Source

pub fn text_with( &mut self, origin: Position, text: impl Into<String>, style: TextStyle, composition: Composition, )

Records plain text with an explicit composition rule.

The plain-text contract is the same as for Self::text.

Source

pub fn line( &mut self, from: Position, to: Position, marker: &Grapheme, style: TextStyle, )

Draws a marker along one cell-space segment using Composition::Overlay.

The segment may be horizontal, vertical, or diagonal. Intersecting lines remain ordinary marker cells; use LineNetwork when crossings must be derived from connectivity.

§Panics

Panics if marker is not exactly one printable, one-cell grapheme.

Source

pub fn line_with( &mut self, from: Position, to: Position, marker: &Grapheme, style: TextStyle, composition: Composition, )

Draws a marker along one cell-space segment with explicit composition.

§Panics

Panics if marker is not exactly one printable, one-cell grapheme.

Source

pub fn polyline( &mut self, points: impl IntoIterator<Item = Position>, marker: &Grapheme, style: TextStyle, )

Draws connected marker segments using Composition::Overlay.

§Panics

Panics if marker is not exactly one printable, one-cell grapheme.

Source

pub fn polyline_with( &mut self, points: impl IntoIterator<Item = Position>, marker: &Grapheme, style: TextStyle, composition: Composition, )

Draws connected marker segments with explicit composition.

§Panics

Panics if marker is not exactly one printable, one-cell grapheme.

Source

pub fn rectangle( &mut self, origin: Position, width: usize, height: usize, marker: &Grapheme, style: TextStyle, )

Draws a cell-aligned marker rectangle using Composition::Overlay.

§Panics

Panics if marker is not exactly one printable, one-cell grapheme.

Source

pub fn rectangle_with( &mut self, origin: Position, width: usize, height: usize, marker: &Grapheme, style: TextStyle, composition: Composition, )

Draws a cell-aligned marker rectangle with explicit composition.

§Panics

Panics if marker is not exactly one printable, one-cell grapheme.

Source

pub fn line_network(&mut self, network: LineNetwork)

Draws horizontal and vertical segments as one connected network.

Intersections between segments in this network are rasterized as corners, tees, and crossings. The resulting cells use Composition::Overlay, like other cell-producing commands.

Source

pub fn line_network_with( &mut self, network: LineNetwork, composition: Composition, )

Draws one connected line network with an explicit composition rule.

The rule combines this network’s rasterized glyphs with earlier Canvas cells. It does not merge this value’s connections with another command.

Source

pub fn cells(&mut self, cells: impl IntoIterator<Item = PositionedCell>)

Records sparse cell contributions using Composition::Overlay.

Source

pub fn cells_with( &mut self, cells: impl IntoIterator<Item = PositionedCell>, composition: Composition, )

Records sparse cell contributions with an explicit composition rule.

Trait Implementations§

Source§

impl Debug for CanvasContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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