pub struct CanvasContext { /* private fields */ }Expand description
Frame-scoped command recorder passed to super::CanvasItem::draw.
Implementations§
Source§impl CanvasContext
impl CanvasContext
pub const fn size(&self) -> Size
pub const fn bounds(&self) -> (Position, Size)
Sourcepub fn view(
&mut self,
origin: Position,
view: View,
width: Option<usize>,
height: Option<usize>,
)
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.
Sourcepub fn view_with(
&mut self,
origin: Position,
view: View,
width: Option<usize>,
height: Option<usize>,
composition: Composition,
)
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.
Sourcepub fn text(
&mut self,
origin: Position,
text: impl Into<String>,
style: TextStyle,
)
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.
Sourcepub fn text_with(
&mut self,
origin: Position,
text: impl Into<String>,
style: TextStyle,
composition: Composition,
)
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.
Sourcepub fn line(
&mut self,
from: Position,
to: Position,
marker: &Grapheme,
style: TextStyle,
)
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.
Sourcepub fn line_with(
&mut self,
from: Position,
to: Position,
marker: &Grapheme,
style: TextStyle,
composition: Composition,
)
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.
Sourcepub fn polyline(
&mut self,
points: impl IntoIterator<Item = Position>,
marker: &Grapheme,
style: TextStyle,
)
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.
Sourcepub fn polyline_with(
&mut self,
points: impl IntoIterator<Item = Position>,
marker: &Grapheme,
style: TextStyle,
composition: Composition,
)
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.
Sourcepub fn rectangle(
&mut self,
origin: Position,
width: usize,
height: usize,
marker: &Grapheme,
style: TextStyle,
)
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.
Sourcepub fn rectangle_with(
&mut self,
origin: Position,
width: usize,
height: usize,
marker: &Grapheme,
style: TextStyle,
composition: Composition,
)
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.
Sourcepub fn line_network(&mut self, network: LineNetwork)
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.
Sourcepub fn line_network_with(
&mut self,
network: LineNetwork,
composition: Composition,
)
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.
Sourcepub fn cells(&mut self, cells: impl IntoIterator<Item = PositionedCell>)
pub fn cells(&mut self, cells: impl IntoIterator<Item = PositionedCell>)
Records sparse cell contributions using Composition::Overlay.
Sourcepub fn cells_with(
&mut self,
cells: impl IntoIterator<Item = PositionedCell>,
composition: Composition,
)
pub fn cells_with( &mut self, cells: impl IntoIterator<Item = PositionedCell>, composition: Composition, )
Records sparse cell contributions with an explicit composition rule.