pub struct Pixels { /* private fields */ }Expand description
A half-block pixel buffer: w × 2·h square pixels over a w × h cell region
(CORE-R42). Ink::BLANK (any Role::Background ink) is an empty pixel.
Implementations§
Source§impl Pixels
impl Pixels
Sourcepub fn pixel_size(&self) -> Size
pub fn pixel_size(&self) -> Size
Buffer dimensions in pixels, w × 2·h (saturated at u16::MAX).
Sourcepub fn resize(&mut self, cells: Size)
pub fn resize(&mut self, cells: Size)
Resize to cells and clear. Reuses the buffer unless it must grow.
Sourcepub fn set(&mut self, x: i32, y: i32, ink: Ink)
pub fn set(&mut self, x: i32, y: i32, ink: Ink)
Set pixel (x, y); off-buffer pixels are ignored.
Sourcepub fn cell_bg(&self, x: i32, y: i32) -> Ink
pub fn cell_bg(&self, x: i32, y: i32) -> Ink
The one ink that stands for cell (x, y)’s two pixels (CORE-R84): the
stronger of the two, or Ink::BLANK when both are empty or the cell is off
the buffer. Dots::blit_over puts it behind a cell’s dots.
Sourcepub fn backdrop(&self, canvas: &mut Canvas)
pub fn backdrop(&self, canvas: &mut Canvas)
Give every glyph already drawn over this buffer’s pixels its cell’s
cell_bg as background (CORE-R86), so line art, sprites and
labels drawn after blit do not punch black boxes into a half-block
picture. Glyphs and inks are kept; cells that already have a background, half and
full blocks, and cells over empty pixels are left alone. Unicode only: an ASCII
canvas has no half blocks to match.
Sourcepub fn shade(&mut self, shader: impl FnMut(i32, i32) -> Ink)
pub fn shade(&mut self, shader: impl FnMut(i32, i32) -> Ink)
Set every pixel to shader(x, y), row by row (CORE-R65): the Pixels analogue
of draw::field, for sampling a simulation lattice (e.g.
through a SampleMap) onto the display pixels.
Sourcepub fn dissolve(&mut self, floor: u8)
pub fn dissolve(&mut self, floor: u8)
Fade a glow’s faint fringe smoothly into the empty sky (CORE-R89, M14), so it ends
in the terminal’s black instead of a ramp’s tinted floor, with no dither. A pixel of
intensity i (as for stronger) below floor is emptied when i < floor / 2,
and in the band [floor / 2, floor) its intensity becomes
i·smoothstep((i − floor/2)/(floor/2)) (a Div pixel keeps its sign about 128),
emptied if that rounds to 0. The fade is a pure function of the pixel’s own
intensity, continuous and non-decreasing in it, so a uniform field stays uniform: no
ordered or noise pattern. Pixels at or above floor, and Phase pixels (no
intensity), are untouched; floor = 0 changes nothing. Allocation-free.
Sourcepub fn blit<F>(&self, canvas: &mut Canvas, ascii: F)
pub fn blit<F>(&self, canvas: &mut Canvas, ascii: F)
Draw the buffer onto canvas, one cell per vertical pixel pair.
Unicode mode: both pixels empty ⇒ cell untouched; top only ⇒ ▀ in the top ink;
bottom only ⇒ ▄ in the bottom ink; both ⇒ ▀ with the top as foreground and
the bottom as background. ASCII mode has no half blocks, so every cell goes
through the scene’s own ascii(x, y, top, bottom) fallback, whose Some((ch, ink)) is written and None leaves the cell untouched (GEN-R10, ADR-0010).