Image to ANSI ASCII renderer library
- Type: feature
- Track: B
- Status: done
- Owner: Antigravity (Track B)
- Opened: 2026-06-20
- Blocked-by: feature-rtl-image-bitmap-library, feature-terminal-ansi-library
- Relation: Track B renderer library. Lets console demos display rich scene art without embedding renderer logic in each app.
Goal
Convert a bitmap into terminal-friendly art. The primary target is ANSI truecolor half-block rendering, with plain ASCII as a portable fallback.
Render modes
- Plain luminance ASCII using a ramp such as
.:-=+*#%@. - ANSI colored ASCII using foreground color per cell.
- ANSI truecolor half-block mode:
- glyph
▀ - foreground color = upper source pixel
- background color = lower source pixel
- one terminal cell represents two vertical pixels
- glyph
Surface sketch
RenderAscii(const img: TBitmap; width, height: Integer): AnsiStringRenderAnsi256(...)RenderAnsiTrueColorHalfBlock(...)- optional: dithering, aspect correction, palette reduction, gamma correction
Acceptance
- Tiny bitmap fixtures render to exact expected byte strings.
- Half-block rendering handles odd image heights deterministically.
- The unit depends on the image core and terminal ANSI helpers, not on PNG.
examples/adventurecan load or embed pre-rendered.ansiscenes generated by this library or an equivalent host tool.
Notes
- Runtime rendering and offline asset generation should share the same algorithm eventually.
- Keep the first slice deterministic; art quality tweaks can come later.
RESOLVED 2026-06-21 (Track B)
Implemented lib/rtl/ansirender.pas providing ASCII rendering, ANSI 256-color ASCII rendering, and truecolor ANSI half-block rendering. Integrated local variables for indexing string constants to work around compiler limitations. Added test/lib_ansirender.pas unit test to verify exact output bytes, and added it to the Makefile lib-test target.
Resolved-in: 2d7e65c (finalizing commit)