hal_core::framebuffer

Trait Draw

Source
pub trait Draw {
    // Required methods
    fn width(&self) -> usize;
    fn height(&self) -> usize;
    fn set_pixel(&mut self, x: usize, y: usize, color: RgbColor) -> &mut Self;
    fn scroll_vert(&mut self, px: isize) -> &mut Self;

    // Provided methods
    fn line_horiz(&mut self, y: usize, len: usize, color: RgbColor) -> &mut Self { ... }
    fn line_vert(&mut self, x: usize, len: usize, color: RgbColor) -> &mut Self { ... }
    fn fill_row(&mut self, y: usize, color: RgbColor) -> &mut Self { ... }
    fn fill_col(&mut self, x: usize, color: RgbColor) -> &mut Self { ... }
    fn fill(&mut self, color: RgbColor) -> &mut Self { ... }
    fn clear(&mut self) -> &mut Self { ... }
    fn into_draw_target(self) -> DrawTarget<Self>
       where Self: Sized { ... }
    fn as_draw_target(&mut self) -> DrawTarget<&mut Self>
       where Self: Sized { ... }
}

Required Methods§

Source

fn width(&self) -> usize

Return the width of the framebuffer in pixels.

Source

fn height(&self) -> usize

Returns the height of the framebuffer in pixels.

Source

fn set_pixel(&mut self, x: usize, y: usize, color: RgbColor) -> &mut Self

Set the pixel at position (x, y) to the provided color.

Source

fn scroll_vert(&mut self, px: isize) -> &mut Self

Provided Methods§

Source

fn line_horiz(&mut self, y: usize, len: usize, color: RgbColor) -> &mut Self

Draw a horizontal line of length len at height y.

By default, this method calls set_pixel in a loop. This works, but implementations can almost certainly provide a more optimal implementation, and are thus encouraged to override this method.

Source

fn line_vert(&mut self, x: usize, len: usize, color: RgbColor) -> &mut Self

Draw a vertical line of length len at column y.

By default, this method calls set_pixel in a loop. This works, but implementations can almost certainly provide a more optimal implementation, and are thus encouraged to override this method.

Source

fn fill_row(&mut self, y: usize, color: RgbColor) -> &mut Self

Source

fn fill_col(&mut self, x: usize, color: RgbColor) -> &mut Self

Source

fn fill(&mut self, color: RgbColor) -> &mut Self

Fill the entire framebuffer with the provided color.

By default, this method calls set_pixel in a loop. This works, but implementations can almost certainly provide a more optimal implementation, and are thus encouraged to override this method.

Source

fn clear(&mut self) -> &mut Self

Clear the entire framebuffer.

By default, this method calls set_pixel in a loop. This works, but implementations can almost certainly provide a more optimal implementation, and are thus encouraged to override this method.

Source

fn into_draw_target(self) -> DrawTarget<Self>
where Self: Sized,

Available on crate feature embedded-graphics-core only.
Source

fn as_draw_target(&mut self) -> DrawTarget<&mut Self>
where Self: Sized,

Available on crate feature embedded-graphics-core only.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<D> Draw for &mut D
where D: Draw,

Source§

fn width(&self) -> usize

Source§

fn height(&self) -> usize

Source§

fn set_pixel(&mut self, x: usize, y: usize, color: RgbColor) -> &mut Self

Source§

fn line_horiz(&mut self, y: usize, len: usize, color: RgbColor) -> &mut Self

Source§

fn line_vert(&mut self, x: usize, len: usize, color: RgbColor) -> &mut Self

Source§

fn fill_row(&mut self, y: usize, color: RgbColor) -> &mut Self

Source§

fn fill_col(&mut self, x: usize, color: RgbColor) -> &mut Self

Source§

fn scroll_vert(&mut self, px: isize) -> &mut Self

Source§

fn fill(&mut self, color: RgbColor) -> &mut Self

Source§

fn clear(&mut self) -> &mut Self

Source§

impl<D, L> Draw for MutexGuard<'_, D, L>
where D: Draw, L: RawMutex,

Source§

fn width(&self) -> usize

Source§

fn height(&self) -> usize

Source§

fn set_pixel(&mut self, x: usize, y: usize, color: RgbColor) -> &mut Self

Source§

fn line_horiz(&mut self, y: usize, len: usize, color: RgbColor) -> &mut Self

Source§

fn line_vert(&mut self, x: usize, len: usize, color: RgbColor) -> &mut Self

Source§

fn fill_row(&mut self, y: usize, color: RgbColor) -> &mut Self

Source§

fn fill_col(&mut self, x: usize, color: RgbColor) -> &mut Self

Source§

fn scroll_vert(&mut self, px: isize) -> &mut Self

Source§

fn fill(&mut self, color: RgbColor) -> &mut Self

Source§

fn clear(&mut self) -> &mut Self

Implementors§