Skip to main content

Module canvas

Module canvas 

Source
Expand description

Sub-cell drawing: plot points/pixels at higher-than-one-per-cell resolution and read them back as glyphs, via retroglyph_core::symbols’s quantizers. Sub-cell drawing: a buffer to plot into before there are pixels to posterize.

retroglyph_core::symbols already provides the quantizers (quantize_half_block and friends): given a block of raw pixels, they pick the best-matching glyph plus two colors. What they don’t provide is anywhere to put those pixels before you have them: a caller drawing a shape, sprite, or heightmap needs a buffer sized in sub-cells, not raw cells, to plot into first. That’s what this module adds.

HalfBlockCanvas, QuadrantCanvas, and SextantCanvas differ only in their sub-cell layout (1x2, 2x2, and 2x3 respectively); each plots full Colors and reads a cell back as whichever quantize_half_block/ quantize_quadrant/ quantize_sextant picks for it. BrailleCanvas is the odd one out: 2x4 dots per cell, but monochrome, since every dot in a braille glyph shares one foreground color, so it plots boolean dots rather than colors and reads a cell back via retroglyph_core::symbols::braille::glyph instead of a quantizer.

A canvas can’t choose a cell’s glyph as it’s plotted: the glyph depends on every sub-cell in that cell, so nothing can be decided until cells is called after the last plot lands.

Structs§

BrailleCanvas
A monochrome canvas with 2x4 sub-cells per cell, using Unicode Braille Patterns.
HalfBlockCanvas
A canvas with 1x2 sub-cells (upper and lower half of each cell).
QuadrantCanvas
A canvas with 2x2 sub-cells per cell.
SextantCanvas
A canvas with 2x3 sub-cells per cell, using Unicode sextants.