Skip to main content

Backend

Trait Backend 

Source
pub trait Backend {
    // Required methods
    fn width(&self) -> u32;
    fn height(&self) -> u32;
    fn fill_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color);
    fn present(&mut self);
    fn poll_event(&mut self) -> Option<Event>;

    // Provided methods
    fn draw_char(&mut self, x: u32, y: u32, ch: char, color: Color) { ... }
    fn draw_text(&mut self, x: u32, y: u32, text: &str, color: Color) { ... }
    fn hline(&mut self, x: u32, y: u32, w: u32, color: Color) { ... }
    fn vline(&mut self, x: u32, y: u32, h: u32, color: Color) { ... }
    fn draw_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color) { ... }
    fn clear(&mut self, color: Color) { ... }
    fn size(&self) -> (u32, u32) { ... }
}

Required Methods§

Source

fn width(&self) -> u32

Framebuffer width in pixels.

Source

fn height(&self) -> u32

Framebuffer height in pixels.

Source

fn fill_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)

Fill a rectangle with a solid color. Out-of-bounds coordinates should be clipped silently.

Source

fn present(&mut self)

Flush the back-buffer to the physical display.

Source

fn poll_event(&mut self) -> Option<Event>

Return the next pending input event, or None if the queue is empty.

Provided Methods§

Source

fn draw_char(&mut self, x: u32, y: u32, ch: char, color: Color)

Draw a single character at (x, y) using the embedded bitmap font.

Source

fn draw_text(&mut self, x: u32, y: u32, text: &str, color: Color)

Draw a string at (x, y) advancing by font::CHAR_W per glyph.

Source

fn hline(&mut self, x: u32, y: u32, w: u32, color: Color)

Draw a 1-pixel horizontal rule.

Source

fn vline(&mut self, x: u32, y: u32, h: u32, color: Color)

Draw a 1-pixel vertical rule.

Source

fn draw_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)

Draw a hollow rectangle (border only, 1-pixel thick).

Source

fn clear(&mut self, color: Color)

Clear the entire framebuffer to color.

Source

fn size(&self) -> (u32, u32)

Return (width, height) as a tuple.

Implementors§