Skip to main content

BasicDrawCreator

Struct BasicDrawCreator 

Source
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

Source

pub fn new() -> Self

Source

pub fn new_with_capacity(cap: usize) -> Self

Source

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.

Source

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.

Source

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

Source

pub fn string_to_basic_draws( pos: impl Into<Point<i32>>, text: &str, fg: Option<Color>, ) -> Vec<BasicDraw>

Convert a string into a Vec

Source

pub fn draw_vertical_bar_graph_simple( &mut self, start: Point<i32>, values: &[usize], height: i32, color: Color, ) -> i32

Source

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

Source

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

Source

pub fn draw_cell( &mut self, pos: impl Into<Point<i32>>, ch: char, fg: Color, bg: Option<Color>, )

Draw a single cell

Source

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, )
where F: FnMut(usize, usize) -> (char, Color, Option<Color>),

the cell fn should return char/fg/bg

Source

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.

Source

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.

Source

pub fn merge_creator(&mut self, to_merge: BasicDrawCreator)

Merge another creator into this one.

Incoming characters overwrite existing positions.

Source

pub fn merge_creator_offset( &mut self, to_merge: BasicDrawCreator, offset: Point<i32>, )

Merge another creator, offsetting all positions by offset.

Source

pub fn align_to_origin(&mut self, origin: Point<i32>)

Translate all draws so the bounding box top-left aligns with origin.

Source

pub fn dump_draws(&mut self) -> Vec<BasicDraw>

Consume the creator and return all draws as a Vec<BasicDraw>.

Trait Implementations§

Source§

impl Debug for BasicDrawCreator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BasicDrawCreator

Source§

fn default() -> BasicDrawCreator

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.