Struct hanbun::Buffer[][src]

pub struct Buffer {
    pub cells: Vec<Cell>,
    pub width: usize,
    pub height: usize,
    // some fields omitted
}

A buffer for storing the state of the cells. You can see it as a drawing canvas.

Examples

let mut buffer;

if let Ok((width, height)) = hanbun::size() {
    buffer = hanbun::Buffer::new(width, height, ' ');
} else {
    return;
}

buffer.set(3, 3);
buffer.draw();

Fields

cells: Vec<Cell>width: usizeheight: usize

Implementations

impl Buffer[src]

pub fn new(width: usize, height: usize, char: char) -> Buffer[src]

Creates a new buffer of width * height cells filled with char.

pub fn draw(&mut self)[src]

Draws the buffer to the screen.

Panics

Panics if an internal write operation operation failed.

pub fn clear(&mut self, char: char)[src]

Clears the buffer using char.

pub fn set(&mut self, x: usize, y: usize)[src]

Sets the cell at (x, y) to a half block.

Panics

Panics if (x, y) is out of the buffer's range.

pub fn color(&mut self, x: usize, y: usize, color: Color)[src]

Colors the cell at (x, y) with the given color.

Panics

Panics if (x, y) is out of the buffer's range.

pub fn print(&mut self, x: usize, y: usize, string: &str)[src]

Prints string to (x, y).

Panics

Panics if (x, y) is out of the buffer's range.

Auto Trait Implementations

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.