Skip to main content

Dots

Struct Dots 

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

A braille dot lattice: 2·w × 4·h square dots over a w × h cell region (CORE-R41).

Each cell stores its dot mask and one ink, that of its most intense lit dot (highest level, or |level − 128| for Role::Div; ties go to the dot set last), since a terminal cell has one colour. Masks and inks are separate arrays so blit scans a dense byte array, which is mostly zeros for sparse line art.

Implementations§

Source§

impl Dots

Source

pub const CELL_W: i32 = 2

Dots per cell horizontally.

Source

pub const CELL_H: i32 = 4

Dots per cell vertically; CELL_H / CELL_W = ASPECT makes the dots square.

Source

pub fn new(cells: Size) -> Self

An empty lattice over cells terminal cells.

Source

pub fn from_cells(x: f64, y: f64) -> (f64, f64)

Dot coordinates of the continuous cell point (x, y), where cell i spans [i, i + 1) (CORE-R64): dot j is centred at cell (j + ½) / CELL_W across and (j + ½) / CELL_H down, so plot lights the dot whose area holds the point, inside the cell that holds it. The one cell → dot convention for every scene; a cell centre (cx + ½, cy + ½) maps to the middle of its 2×4 block.

Source

pub fn dot_size(&self) -> Size

Lattice dimensions in dots, 2·w × 4·h (saturated at u16::MAX per axis).

Source

pub fn resize(&mut self, cells: Size)

Resize to cells and clear. Reuses the buffers unless they must grow.

Source

pub fn clear(&mut self)

Unlight every dot.

Source

pub fn set(&mut self, x: i32, y: i32, ink: Ink)

Light dot (x, y) with ink; off-lattice dots are ignored.

Source

pub fn plot(&mut self, x: f64, y: f64, ink: Ink)

Light the dot nearest to (x, y) (dot units); non-finite or off-lattice points are ignored, so simulation code never casts NaN to a coordinate.

Source

pub fn stipple(&mut self, x: i32, y: i32, p: f64, salt: u64, ink: Ink)

Light dot (x, y) with ink when stipple_keep(salt, x, y, p) (CORE-R107): a probability cloud sampled with fixed per-dot thresholds, as electron_orbitals’ clouds are. Off-lattice dots are ignored.

Source

pub fn stipple_puff( &mut self, cx: f64, cy: f64, sigma: f64, peak: f64, salt: u64, ink: Ink, )

Light a small Gaussian stipple atom about (cx, cy) (dot units, CORE-R108): each dot within 3σ is kept by stipple_keep at peak·e^(−r²/2σ²), and the dot nearest the centre is always lit, so an atom never vanishes. The density only grows with sigma and peak, so a swelling atom only gains dots. A non-finite or non-positive sigma leaves just the centre dot; peak ≤ 0 or a non-finite centre lights nothing.

Source

pub fn line(&mut self, x0: f64, y0: f64, x1: f64, y1: f64, ink: Ink)

Light the Bresenham segment from (x0, y0) to (x1, y1) (dot units, rounded), both endpoints inclusive, clipped to the lattice (CORE-R51). Non-finite endpoints draw nothing, and the walk is capped at 4·(dot width + dot height) steps, so wild coordinates stay cheap.

Source

pub fn disc(&mut self, x: f64, y: f64, r: f64, ink: Ink)

Light the filled disc of radius r (dot units, so round on screen) about (x, y): every dot whose centre lies within r, plus the dot nearest the centre, so a radius below ½ is one dot (CORE-R82). Clipped to the lattice; a non-finite centre or radius, or r < 0, lights nothing. Bobs, suns and grains in line-art scenes.

Source

pub fn contour( &mut self, values: &[f32], w: usize, h: usize, level: f32, to_dot: impl Fn(f64, f64) -> (f64, f64), ink: Ink, )

Draw the iso-contour v = level of a row-major w × h node field, one dot thick, by marching squares (CORE-R105). to_dot(x, y) maps continuous node coordinates (node (i, j) at (i, j)) to dot coordinates. Too-short fields and w or h below 2 draw nothing; nothing allocates.

Source

pub fn contour_by( &mut self, values: &[f32], w: usize, h: usize, level: f32, to_dot: impl Fn(f64, f64) -> (f64, f64), ink: impl FnMut(usize, usize) -> Option<Ink>, )

contour with the ink chosen per cell of four nodes: ink(i, j) is asked only for cells the level crosses ((i, j) the top-left node) and None skips the cell, so a contour can be coloured by sign, age or a sampled variable.

Source

pub fn contour_cell( &mut self, corners: [f32; 4], level: f32, (i, j): (usize, usize), to_dot: impl Fn(f64, f64) -> (f64, f64), ink: Ink, )

Draw the level set v = level inside one cell of four nodes (CORE-R105), for scenes that cull cells themselves. corners are the values at nodes (i, j), (i+1, j), (i+1, j+1), (i, j+1) (clockwise on screen); a node is below the level when v < level. Each straddling edge’s crossing is linearly interpolated, and the crossings are joined by line: two crossings make one piece, four (a saddle) two, paired in edge order. Non-finite corners draw nothing.

Source

pub fn contour_cell_refined( &mut self, corners: [f32; 4], level: f32, (i, j): (usize, usize), k: usize, to_dot: impl Fn(f64, f64) -> (f64, f64), ink: Ink, )

contour_cell with the cell refined into k × k sub-cells whose corners are bilinear in the four node values (CORE-R106): where one node spans many dots the level set is traced as a smooth curve (the bilinear surface’s own level set, to within 1/k of a cell) instead of one straight chord per cell. k ≤ 1 is plain contour_cell; k is capped at 16. Sub-cells the level does not cross are skipped; nothing allocates.

Source

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

Whether dot (x, y) is lit; false off the lattice.

Source

pub fn cell_mask(&self, cx: i32, cy: i32) -> Option<u8>

The dot mask of cell (cx, cy) (bit layout as braille; 0 = no dot lit), or None off the region (CORE-R64).

Source

pub fn blit(&self, canvas: &mut Canvas)

Write every cell with at least one lit dot as its braille glyph (or the dot-count ASCII fallback) and ink; cells with no lit dots are left untouched, so a lattice layers over earlier drawing.

Source

pub fn blit_over(&self, canvas: &mut Canvas, under: &Pixels)

blit over a half-block layer (CORE-R84): each written cell gets Pixels::cell_bg of under as its background, so a glow drawn as Pixels carries on under a point cloud or a track instead of stopping at the first dotted cell. under should cover the same cells; outside it the background is blank. ASCII mode has no half blocks, so there it is plain blit.

Trait Implementations§

Source§

impl Clone for Dots

Source§

fn clone(&self) -> Self

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 Dots

Source§

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

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

impl Default for Dots

Source§

fn default() -> Self

A 1×1-cell lattice, the placeholder until a scene’s first resize.

Auto Trait Implementations§

§

impl Forget for Dots

§

impl Freeze for Dots

§

impl Move for Dots

§

impl RefUnwindSafe for Dots

§

impl Send for Dots

§

impl Sync for Dots

§

impl Unpin for Dots

§

impl UnsafeUnpin for Dots

§

impl UnwindSafe for Dots

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V