Skip to main content

BrailleCanvas

Struct BrailleCanvas 

Source
pub struct BrailleCanvas { /* private fields */ }
Expand description

A monochrome canvas with 2x4 sub-cells per cell, using Unicode Braille Patterns.

The densest character-grid raster there is: 8 dots per cell, which on a 100x40 grid is a 200x160 bitmap. The catch is in the name of the trade: all 8 dots share one foreground color, so this draws shapes, not pictures. Ideal for contour lines, a pixel-accurate outline, or a high-resolution minimap silhouette.

Dot addressing goes through retroglyph_core::symbols::braille::DOTS and retroglyph_core::symbols::braille::glyph rather than a locally re-derived bit table: dot bit positions follow Braille’s historical numbering (down the left column, then the right, then the two 8-dot extensions appended underneath), not raster order, and that table already exists in retroglyph-core.

Implementations§

Source§

impl BrailleCanvas

Source

pub fn new(cols: u16, rows: u16) -> Self

A canvas covering cols x rows cells, i.e. cols * 2 x rows * 4 plottable points.

Source

pub const fn size(&self) -> (usize, usize)

Plottable size, in dots.

Source

pub fn clear(&mut self)

Clears every dot.

Source

pub fn plot(&mut self, x: i32, y: i32)

Sets the dot at (x, y). Out-of-bounds coordinates are ignored; see HalfBlockCanvas::plot.

Source

pub fn unplot(&mut self, x: i32, y: i32)

Clears the dot at (x, y).

Source

pub fn get(&self, x: i32, y: i32) -> bool

Whether the dot at (x, y) is set.

Source

pub fn line(&mut self, x0: i32, y0: i32, x1: i32, y1: i32)

Draws a line between two dot coordinates (Bresenham).

The one drawing primitive worth having built in: contours, outlines, and route overlays are all lines, and hand-rolling Bresenham per caller is exactly the sort of duplication a shared crate exists to prevent.

Source

pub fn glyph(&self, col: usize, row: usize) -> char

The Braille character for cell (col, row), or braille::BLANK if out of bounds.

Source

pub fn cells(&self) -> impl Iterator<Item = (u16, u16, char)> + '_

Yields (col, row, glyph) for every cell.

Trait Implementations§

Source§

impl Clone for BrailleCanvas

Source§

fn clone(&self) -> BrailleCanvas

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BrailleCanvas

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.