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§
Sourcefn draw_horizontal_line(&mut self, x: u16, y: u16, width: u16, cell: Cell)
fn draw_horizontal_line(&mut self, x: u16, y: u16, width: u16, cell: Cell)
Draw a horizontal line of cells.
Sourcefn draw_vertical_line(&mut self, x: u16, y: u16, height: u16, cell: Cell)
fn draw_vertical_line(&mut self, x: u16, y: u16, height: u16, cell: Cell)
Draw a vertical line of cells.
Sourcefn draw_rect_filled(&mut self, rect: Rect, cell: Cell)
fn draw_rect_filled(&mut self, rect: Rect, cell: Cell)
Draw a filled rectangle.
Sourcefn draw_rect_outline(&mut self, rect: Rect, cell: Cell)
fn draw_rect_outline(&mut self, rect: Rect, cell: Cell)
Draw a rectangle outline using a single cell character.
Sourcefn print_text(&mut self, x: u16, y: u16, text: &str, base_cell: Cell) -> u16
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.
Sourcefn print_text_clipped(
&mut self,
x: u16,
y: u16,
text: &str,
base_cell: Cell,
max_x: u16,
) -> u16
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.
Sourcefn draw_border(&mut self, rect: Rect, chars: BorderChars, base_cell: Cell)
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.
Sourcefn draw_box(
&mut self,
rect: Rect,
chars: BorderChars,
border_cell: Cell,
fill_cell: Cell,
)
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.
Sourcefn paint_area(
&mut self,
rect: Rect,
fg: Option<PackedRgba>,
bg: Option<PackedRgba>,
)
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.