pub struct Context<'a> { /* private fields */ }
Expand description
Implementations§
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn new(
width: u16,
height: u16,
x_bounds: [f64; 2],
y_bounds: [f64; 2],
marker: Marker,
) -> Self
pub fn new( width: u16, height: u16, x_bounds: [f64; 2], y_bounds: [f64; 2], marker: Marker, ) -> Self
Create a new Context with the given width and height measured in terminal columns and rows
respectively. The x
and y
bounds define the specific area of some coordinate system that
will be drawn on the canvas. The marker defines the type of points used to draw the shapes.
Applications should not use this directly but rather use the Canvas
widget. This will be
created by the Canvas::paint
method and passed to the closure that is used to draw on
the canvas.
The x
and y
bounds should be specified as left/right and bottom/top respectively. For
example, if you want to draw a map of the world, you might want to use the following bounds:
use ratatui::{symbols, widgets::canvas::Context};
let ctx = Context::new(
100,
100,
[-180.0, 180.0],
[-90.0, 90.0],
symbols::Marker::Braille,
);
Sourcepub fn layer(&mut self)
pub fn layer(&mut self)
Save the existing state of the grid as a layer.
Save the existing state as a layer to be rendered and reset the grid to its initial state for the next layer.
This allows the canvas to be drawn in multiple layers. This is useful if you want to
draw multiple shapes on the Canvas
in specific order.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Context<'a>
impl<'a> !RefUnwindSafe for Context<'a>
impl<'a> !Send for Context<'a>
impl<'a> !Sync for Context<'a>
impl<'a> Unpin for Context<'a>
impl<'a> !UnwindSafe for Context<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more