Skip to main content

Module snapcompact_render

Module snapcompact_render 

Source
Expand description

Snapcompact frame rendering.

Rasterizes pre-normalized conversation text onto a size-wide bitmap (height hugs the rows the text actually needs) using one of the bundled public-domain pixel fonts, then encodes it as PNG:

  • 5x8 — X.org BDF font (legacy shape).
  • 8x8 — unscii-8 hex font (Latin-1 subset), the square cell that won the snapcompact SQuAD evals.
  • 6x12 / 8x13 — X.org misc BDF fonts (higher-density eval winners).
  • silver — bundled TrueType font for CJK and other non-Latin text.

Shape controls, all eval-validated in packages/snapcompact:

  • variantsent cycles glyph ink through six hues at sentence boundaries; bw prints plain black ink (best for Anthropic readers).
  • lineRepeat — prints every text line N times; copies after the first sit on a pale highlight band. Redundancy coding: two looks per glyph at half the density (“8x8r” shapes).
  • cellWidth/cellHeight — target cell size. When it differs from the font’s natural cell, glyphs are rasterized at native size and the canvas is Lanczos3-resampled to the target (anisotropic stretch, e.g. the OpenAI-optimal “6x6u” shape), producing an anti-aliased RGB frame.
  • stretchfalse disables resampling: glyphs print at natural size on the requested cell box while staying indexed (e.g. 8x13 glyphs on an 8x16 pitch, the “8on16” shapes). true/unset keeps the auto rule above.
  • columns2 flows pre-wrapped \n-separated lines down two newspaper columns (the “doc” shapes); word wrap and pagination happen in the TypeScript caller.
  • dim spansU+000E/U+000F in the text toggle dim gray ink on/off without occupying a cell; the TypeScript serializer wraps tool output in them so archived conversation reads louder than archived tool noise.
  • line breaksU+2588 (FULL BLOCK) fills its entire cell with pitch black ink regardless of variant or dim state; the TypeScript normalizer folds newline runs to it so line structure survives whitespace collapse at a one-cell cost.

Text normalization, frame chunking, provider shape selection, and archive management live in packages/snapcompact/src/snapcompact.ts; this module is only the hot text -> PNG bytes path.

Structs§

SnapcompactRenderOptions
Shape options for one snapcompact frame.

Enums§

SnapcompactError
Renderer error type.

Functions§

render_snapcompact_png
Render one snapcompact frame on a libuv worker: print pre-normalized text onto a size-wide bitmap and encode it as PNG.
snapcompact_supported_chars
Return the subset of chars that the named snapcompact font can render.