Skip to main content

quantize_half_block

Function quantize_half_block 

Source
pub fn quantize_half_block(pixels: [impl Into<Pixel>; 2]) -> Glyph
Expand description

Posterizes a 1-wide x 2-tall pixel block ([top, bottom]) to ' '/// plus two representative colors.

This is the lowest-fidelity, most compatible option: plain Unicode Block Elements, supported by essentially every monospace terminal font.

See the 16_subcell_image example for quantize_half_block in action: https://main.retroglyph.dev/examples/16_subcell_image/terminal/.

§Examples

use retroglyph_core::symbols::quantize_half_block;

let glyph = quantize_half_block([(255, 255, 255), (0, 0, 0)]);
assert_eq!(glyph.ch, '▀'); // top half set, bottom clear

Never panics: pixels is a fixed-size 2-element array, so there is no length to validate and no index into it that can be out of bounds.