pub struct BasicDrawCreator {
pub draws: HashMap<Point<i32>, TerminalChar>,
}Expand description
Collector for drawable terminal operations.
Fields§
§draws: HashMap<Point<i32>, TerminalChar>Implementations§
Source§impl BasicDrawCreator
impl BasicDrawCreator
pub fn new() -> Self
pub fn new_with_capacity(cap: usize) -> Self
Sourcepub fn draw_char(&mut self, pos: impl Into<Point<i32>>, chr: TerminalChar)
pub fn draw_char(&mut self, pos: impl Into<Point<i32>>, chr: TerminalChar)
Draw a single character at pos.
If a character already exists at this position, it is replaced.
Sourcepub fn draw_line(
&mut self,
p1: impl Into<Point<i32>>,
p2: impl Into<Point<i32>>,
chr: TerminalChar,
)
pub fn draw_line( &mut self, p1: impl Into<Point<i32>>, p2: impl Into<Point<i32>>, chr: TerminalChar, )
Draw a straight line from p1 to p2 (inclusive) using Bresenham’s algorithm.
Both endpoints are included. Each point on the line receives chr.
Sourcepub fn draw_text(
&mut self,
pos: impl Into<Point<i32>>,
text: &str,
fg: Option<Color>,
)
pub fn draw_text( &mut self, pos: impl Into<Point<i32>>, text: &str, fg: Option<Color>, )
Draw a horizontal text string starting at pos.
Each character advances x by 1. Newlines are interpreted (advances y and resets x to start.x).
If fg is Some(Color) it will be used
Sourcepub fn string_to_basic_draws(
pos: impl Into<Point<i32>>,
text: &str,
fg: Option<Color>,
) -> Vec<BasicDraw>
pub fn string_to_basic_draws( pos: impl Into<Point<i32>>, text: &str, fg: Option<Color>, ) -> Vec<BasicDraw>
Convert a string into a Vec
pub fn draw_vertical_bar_graph_simple( &mut self, start: Point<i32>, values: &[usize], height: i32, color: Color, ) -> i32
Sourcepub fn draw_vertical_bar_graph(
&mut self,
start: Point<i32>,
values: &[usize],
cfg: &VerticalBarGraphConfig,
) -> i32
pub fn draw_vertical_bar_graph( &mut self, start: Point<i32>, values: &[usize], cfg: &VerticalBarGraphConfig, ) -> i32
Draw a vertical bar graph of the supplied config
Sourcepub fn draw_line_graph(
&mut self,
start: Point<i32>,
values: &[usize],
cfg: &LineGraphConfig,
) -> i32
pub fn draw_line_graph( &mut self, start: Point<i32>, values: &[usize], cfg: &LineGraphConfig, ) -> i32
Draw a line graph using a config struct.
Returns start.y + height
Sourcepub fn draw_cell(
&mut self,
pos: impl Into<Point<i32>>,
ch: char,
fg: Color,
bg: Option<Color>,
)
pub fn draw_cell( &mut self, pos: impl Into<Point<i32>>, ch: char, fg: Color, bg: Option<Color>, )
Draw a single cell
Sourcepub fn draw_grid_from_fn<F>(
&mut self,
origin: Point<i32>,
cols: usize,
rows: usize,
stride_x: i32,
stride_y: i32,
cell_fn: F,
)
pub fn draw_grid_from_fn<F>( &mut self, origin: Point<i32>, cols: usize, rows: usize, stride_x: i32, stride_y: i32, cell_fn: F, )
the cell fn should return char/fg/bg
Sourcepub fn draw_horizontal_bar(
&mut self,
pos: impl Into<Point<i32>>,
len: i32,
chr: char,
fg: Color,
)
pub fn draw_horizontal_bar( &mut self, pos: impl Into<Point<i32>>, len: i32, chr: char, fg: Color, )
Draw a horizontal bar starting at pos with len characters of chr.
Sourcepub fn get_bounding_box(&self) -> Rect<i32>
pub fn get_bounding_box(&self) -> Rect<i32>
Compute the axis-aligned bounding box containing all drawn points.
Returns (0, 0),(0, 0) if empty.
Sourcepub fn merge_creator(&mut self, to_merge: BasicDrawCreator)
pub fn merge_creator(&mut self, to_merge: BasicDrawCreator)
Merge another creator into this one.
Incoming characters overwrite existing positions.
Sourcepub fn merge_creator_offset(
&mut self,
to_merge: BasicDrawCreator,
offset: Point<i32>,
)
pub fn merge_creator_offset( &mut self, to_merge: BasicDrawCreator, offset: Point<i32>, )
Merge another creator, offsetting all positions by offset.
Sourcepub fn align_to_origin(&mut self, origin: Point<i32>)
pub fn align_to_origin(&mut self, origin: Point<i32>)
Translate all draws so the bounding box top-left aligns with origin.
Sourcepub fn dump_draws(&mut self) -> Vec<BasicDraw>
pub fn dump_draws(&mut self) -> Vec<BasicDraw>
Consume the creator and return all draws as a Vec<BasicDraw>.