Skip to main content

Draw

Trait Draw 

Source
pub trait Draw {
    // Required methods
    fn draw_horizontal_line(&mut self, x: u16, y: u16, width: u16, cell: Cell);
    fn draw_vertical_line(&mut self, x: u16, y: u16, height: u16, cell: Cell);
    fn draw_rect_filled(&mut self, rect: Rect, cell: Cell);
    fn draw_rect_outline(&mut self, rect: Rect, cell: Cell);
    fn print_text(&mut self, x: u16, y: u16, text: &str, base_cell: Cell) -> u16;
    fn print_text_clipped(
        &mut self,
        x: u16,
        y: u16,
        text: &str,
        base_cell: Cell,
        max_x: u16,
    ) -> u16;
    fn draw_border(&mut self, rect: Rect, chars: BorderChars, base_cell: Cell);
    fn draw_box(
        &mut self,
        rect: Rect,
        chars: BorderChars,
        border_cell: Cell,
        fill_cell: Cell,
    );
    fn paint_area(
        &mut self,
        rect: Rect,
        fg: Option<PackedRgba>,
        bg: Option<PackedRgba>,
    );
}
Expand description

Extension trait for drawing on a Buffer.

Required Methods§

Source

fn draw_horizontal_line(&mut self, x: u16, y: u16, width: u16, cell: Cell)

Draw a horizontal line of cells.

Source

fn draw_vertical_line(&mut self, x: u16, y: u16, height: u16, cell: Cell)

Draw a vertical line of cells.

Source

fn draw_rect_filled(&mut self, rect: Rect, cell: Cell)

Draw a filled rectangle.

Source

fn draw_rect_outline(&mut self, rect: Rect, cell: Cell)

Draw a rectangle outline using a single cell character.

Source

fn print_text(&mut self, x: u16, y: u16, text: &str, base_cell: Cell) -> u16

Print text at the given coordinates using the cell’s colors/attrs.

Characters replace the cell content; fg/bg/attrs come from base_cell. Stops at the buffer edge. Returns the x position after the last character.

Source

fn print_text_clipped( &mut self, x: u16, y: u16, text: &str, base_cell: Cell, max_x: u16, ) -> u16

Print text with a right-side clipping boundary.

Like print_text but stops at max_x (exclusive) instead of the buffer edge. Returns the x position after the last character.

Source

fn draw_border(&mut self, rect: Rect, chars: BorderChars, base_cell: Cell)

Draw a border around a rectangle using the given characters.

The border is drawn inside the rectangle (edges + corners). The cell’s fg/bg/attrs are applied to all border characters.

Source

fn draw_box( &mut self, rect: Rect, chars: BorderChars, border_cell: Cell, fill_cell: Cell, )

Draw a border and fill the interior.

Draws a border using border_chars and fills the interior with fill_cell. If the rect is too small for an interior (width or height <= 2), only the border is drawn.

Source

fn paint_area( &mut self, rect: Rect, fg: Option<PackedRgba>, bg: Option<PackedRgba>, )

Set all cells in a rectangular area to the given fg/bg/attrs without changing cell content.

Useful for painting backgrounds or selection highlights.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Draw for Buffer

Source§

impl<'a> Draw for Frame<'a>