Struct tui::widgets::canvas::Canvas[][src]

pub struct Canvas<'a, F> where
    F: Fn(&mut Context<'_>), 
{ /* fields omitted */ }

The Canvas widget may be used to draw more detailed figures using braille patterns (each cell can have a braille character in 8 different positions).

Examples

Canvas::default()
    .block(Block::default().title("Canvas").borders(Borders::ALL))
    .x_bounds([-180.0, 180.0])
    .y_bounds([-90.0, 90.0])
    .paint(|ctx| {
        ctx.draw(&Map {
            resolution: MapResolution::High,
            color: Color::White
        });
        ctx.layer();
        ctx.draw(&Line {
            x1: 0.0,
            y1: 10.0,
            x2: 10.0,
            y2: 10.0,
            color: Color::White,
        });
        ctx.draw(&Rectangle {
            x: 10.0,
            y: 20.0,
            width: 10.0,
            height: 10.0,
            color: Color::Red
        });
    });

Implementations

impl<'a, F> Canvas<'a, F> where
    F: Fn(&mut Context<'_>), 
[src]

pub fn block(self, block: Block<'a>) -> Canvas<'a, F>[src]

pub fn x_bounds(self, bounds: [f64; 2]) -> Canvas<'a, F>[src]

pub fn y_bounds(self, bounds: [f64; 2]) -> Canvas<'a, F>[src]

pub fn paint(self, f: F) -> Canvas<'a, F>[src]

Store the closure that will be used to draw to the Canvas

pub fn background_color(self, color: Color) -> Canvas<'a, F>[src]

pub fn marker(self, marker: Marker) -> Canvas<'a, F>[src]

Change the type of points used to draw the shapes. By default the braille patterns are used as they provide a more fine grained result but you might want to use the simple dot or block instead if the targeted terminal does not support those symbols.

Examples

Canvas::default().marker(symbols::Marker::Braille).paint(|ctx| {});

Canvas::default().marker(symbols::Marker::Dot).paint(|ctx| {});

Canvas::default().marker(symbols::Marker::Block).paint(|ctx| {});

Trait Implementations

impl<'a, F> Default for Canvas<'a, F> where
    F: Fn(&mut Context<'_>), 
[src]

impl<'a, F> Widget for Canvas<'a, F> where
    F: Fn(&mut Context<'_>), 
[src]

Auto Trait Implementations

impl<'a, F> RefUnwindSafe for Canvas<'a, F> where
    F: RefUnwindSafe

impl<'a, F> Send for Canvas<'a, F> where
    F: Send

impl<'a, F> Sync for Canvas<'a, F> where
    F: Sync

impl<'a, F> Unpin for Canvas<'a, F> where
    F: Unpin

impl<'a, F> UnwindSafe for Canvas<'a, F> where
    F: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.