Pixel
A ```pixel fence draws a sprite from data: a legend, then a grid of characters. There is no
image file to version, no model and no third-party asset: the same grid gives the same SVG, byte for
byte. In v1 it plays in a film (motion) and is drawn still (first frame) on a web story card
(webstory); a deck or a page comes later.
Live demo
Syntax
Markdown
The legend comes first, one char = per line, then a blank line and the grid. More grids,
each after a blank line, are the frames of an animation. The paragraph after the fence is the
caption of the scene. --- type= is optional: a scene that starts with a ```pixel fence is
a pixel scene.
Colours
| Value | Meaning |
|---|---|
bg, surface, text, muted, accent | colours of the theme: the sprite follows dark mode |
data.peach, data.mint, data., data.… | the data colours of the motion themes |
#rgb, #rrggbb, #rrggbbaa | a fixed colour |
transparent | an empty cell |
0, 1, 2… | a colour of the palette named by palette= |
Any other value is an error, with its line.
Named palettes
palette= on the fence lets the legend write a colour by its index in that palette, from 0.
The index becomes its hex colour when the fence is read, so the typed JSON and the rendered SVG hold
the colour itself. An index without palette=, an index past the end of the palette and an unknown
palette are errors, with their line. Indices mix freely with theme tokens and hex colours. A fence
the generator writes holds hex colours already. The palette= of a ::pixel recipe is another key:
it picks one of the generator's presets (ink, moss, dusk, ember, tide), which colour the
body, shade and outline of a generated sprite or texture, and stay the same in dark mode.
Markdown
| Palette | Colours | What it is |
|---|---|---|
grey-4 | 4 | black, two greys, white, evenly spaced |
green-4 | 4 | the four greens of an early handheld screen, darkest first |
teletext-8 | 8 | black, red, green, yellow, blue, magenta, cyan, white |
cga-16 | 16 | the sixteen colours of the IBM CGA adapter, in its own order |
These are colour sets fixed by a hardware or a broadcast standard. Palettes drawn by an artist come
later, once their licence is checked. In code, PIXEL_ and pixelPaletteColor of
@recit/ hold them.
Pixel text
pixelText(text, options) of @recit/ draws a text in Récit's own pixel font, as a
grid and its legend ready for pixelToFence. Each glyph takes 3 × 5 cells: the capitals, the digits
and . , ! ?. A lowercase letter is drawn as its capital and an accented letter as its base
letter (é as E). Lines split on a line break and are padded to the widest. The font was drawn
for Récit, so it needs no licence line in NOTICE.md.
| Option | Default | What it does |
|---|---|---|
ink | k | the legend key of an inked cell, never . |
color | text | the colour of the ink: a theme token or a hex |
spacing | 1 | empty columns between two glyphs |
lineSpacing | 1 | empty rows between two lines |
A character the font cannot draw is an error that names it (pixelTextUnsupported lists them
first), and so are an empty text, a spacing that is not a whole number of cells 0 or more, and a
grid wider or taller than 128 cells.
TypeScript
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
id | string | — | Stable id of the image, the same in every language |
alt | string | — | Text alternative: a warning when missing, an error in strict mode |
scale | auto | number | auto | Pixels per cell; auto fills the space of the scene |
fps | number | 4 | Frames per second of the frames |
reveal | scan | dissolve | none | none | Entrance in a film: scan draws the rows top to bottom, dissolve shows the cells in a scattered order |
cycle | string | — | Legend keys whose colours turn one step per frame at fps in a film (cycle=abc) |
palette | string | — | A named palette: the legend may write a colour by its index |
caption | string | — | One line under the image (or the paragraph after the fence) |
A film keeps the scene on screen for its reveal and two loops of its frames. Under
prefers-, the first frame is shown, fully drawn.
On a web story card (format:), a ```pixel fence or a ::pixel{gen=
directive is drawn still as an inline SVG (the first frame, no animation), on an ordinary --- card
separator with no type=pixel. A missing or blank alt raises the pixel-alt warning (an error
under recit validate --) and renders the image decorative:
card.story.md
Errors
Every problem points to its line in the story, and nothing is corrected silently:
story.md: 24 (pixel): row 3 has 7 cells, expected 8 - a character missing from the legend, an unknown token, an invalid hex colour;
- frames of different sizes;
- a grid larger than 128 × 128 cells, or more than 32 frames (provisional caps);
- two keys of the same colour: a warning.
JSON twin
In the typed JSON of a story, the fence stays in the scene body, like any Markdown. The props are
validated by PixelPropsSchema and PixelBlockSchema of @recit/.
In code
@recit/ holds the pure module: parsePixelFence, pixelPicture (merged
rectangles), pixelToSvg, pixelToHast, pixelToFence, the remark plugins remarkPixel and
remarkPixelFences, createPixelDirective, and pixelText with PIXEL_FONT (the pixel font).
PixelImage (React, server-rendered, role="img") is exported by @recit/.
See the films on the images page of motion.recit.dev.