pub struct Painter<'a, 'b> { /* private fields */ }
Implementations§
source§impl<'a, 'b> Painter<'a, 'b>
impl<'a, 'b> Painter<'a, 'b>
sourcepub fn get_point(&self, x: f64, y: f64) -> Option<(usize, usize)>
pub fn get_point(&self, x: f64, y: f64) -> Option<(usize, usize)>
Convert the (x, y) coordinates to location of a point on the grid
Examples:
use ratatui::{symbols, widgets::canvas::{Painter, Context}};
let mut ctx = Context::new(2, 2, [1.0, 2.0], [0.0, 2.0], symbols::Marker::Braille);
let mut painter = Painter::from(&mut ctx);
let point = painter.get_point(1.0, 0.0);
assert_eq!(point, Some((0, 7)));
let point = painter.get_point(1.5, 1.0);
assert_eq!(point, Some((1, 3)));
let point = painter.get_point(0.0, 0.0);
assert_eq!(point, None);
let point = painter.get_point(2.0, 2.0);
assert_eq!(point, Some((3, 0)));
let point = painter.get_point(1.0, 2.0);
assert_eq!(point, Some((0, 0)));
sourcepub fn paint(&mut self, x: usize, y: usize, color: Color)
pub fn paint(&mut self, x: usize, y: usize, color: Color)
Paint a point of the grid
Examples:
use ratatui::{style::Color, symbols, widgets::canvas::{Painter, Context}};
let mut ctx = Context::new(1, 1, [0.0, 2.0], [0.0, 2.0], symbols::Marker::Braille);
let mut painter = Painter::from(&mut ctx);
let cell = painter.paint(1, 3, Color::Red);
Trait Implementations§
Auto Trait Implementations§
impl<'a, 'b> !RefUnwindSafe for Painter<'a, 'b>
impl<'a, 'b> !Send for Painter<'a, 'b>
impl<'a, 'b> !Sync for Painter<'a, 'b>
impl<'a, 'b> Unpin for Painter<'a, 'b>
impl<'a, 'b> !UnwindSafe for Painter<'a, 'b>
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
Mutably borrows from an owned value. Read more