Reference
Scenes
A scene is one JSON object. Elements are drawn in order, each on top of the last. This page is the format itself; every element type is on Elements.
A Levni scene is one JSON object. Elements are drawn in order, each on top of the previous one.
{ "seed": 5, "background": "paper", "elements": [ { "type": "prop", "name": "rocket", "x": 600, "y": 336, "size": 360 } ] }
Render it: npx @levni/levni render scene.json out.png (or .webp, .svg). The command prints the layout critic's notes; fix them or ignore them on purpose.
A machine-readable outline is in scene.schema.json.


recolor swaps house colours per element; a style on the scene re-inks everything.Scene fields#
| field | type | default | meaning |
|---|---|---|---|
elements |
array | [] |
what to draw, in order |
seed |
integer | 1 |
all randomness (hand wobble, ink, crowds) follows it; same seed, same picture |
background |
colour | paper |
canvas colour; blue, ink or dark turn line art to paper automatically |
clip |
[x, y, w, h] |
none | everything stays inside this hand-drawn card |
hand |
boolean | true |
false draws plain SVG strokes instead of pressure-brush ink |
plateShift |
number | 3.2 |
riso misregistration: how far each ink colour's plate drifts |
boil |
integer | seed |
seed of the crayon filter only (animate it for a hand-drawn shimmer) |
t |
0..1 | 0 |
animation time; trees sway, clouds drift, flags wave |
locale |
string | en |
locale used to upper-case label text (tr gives dotted İ) |
style |
string or object | riso |
style pack: riso or miniature, or your own inks as { "blue": "#123456", "coral": "#FF8800" } (house colour names: paper, white, ink, blue, coral, green, mustard, dark, tone, tone-coral, tone-green, tone-mustard; the rest keep the house hex). Recolours every prop, panel and texture. |
finish |
string | crayon |
crayon: hand-inked lines, riso plates, paper grain. soft: clean edges and a fine film grain, for the ribbon look. Both finishes are applied to the pixels by rasterize() (about 0.15 s for a crayon cover); LEVNI_RASTER=rsvg hands the filter back to the SVG renderer |
grain |
number | 0.16 |
strength of the film grain in the soft finish |
screen |
string or object | none | print pass on .png/.webp: the finished picture is averaged into cell-px blocks and Bayer-dithered to the nearest of paper + inks. Presets: 1bit, riso, blueprint, gameboy, newsprint; or {preset?, cell, matrix, inks, paper, spread}. Flat paper and flat ink stay solid |
format |
string | cover |
canvas preset: cover 1200×673, og 1200×630, square 1080×1080, story 1080×1920, youtube 1280×720, poster 1200×1600, poster-tall 1200×1800, a4 1240×1754 |
canvas |
[w, h] |
none | explicit canvas size (64..8192 each); wins over format |
reflow |
boolean | false |
recompose a scene authored for 1200×673 onto the chosen canvas (below). levni render --format <name> sets format and reflow |
reflowFrom |
[w, h] |
[1200, 673] |
the canvas the scene was authored for |
title |
object | none | headline layer drawn above everything (below) |
Canvas and colours#
The default canvas is 1200 × 673 px (cover). Other sizes: see "Formats and reflow". Coordinates are pixels from the top left. Without format or canvas a scene renders exactly as before.
Colour names: blue (panels), ink (lines), coral, mustard, green, paper (cream), white, dark, tone (light blue), tone-coral, tone-green, tone-mustard, none. Any #rrggbb also works.
House rule: at most two main inks plus paper per scene; a third colour only as a small accent. For sensitive subjects use only blue, tone and paper (props take "palette": "blue").
Composition rules that work#
- One focus. One element clearly the largest (≥ 220 px); everything else serves it.
- Full but breathing. Fill the frame, keep air around the focus.
- Bleeding off the edge is fine when bold (a giant symbol cropped by a panel, a crowd cut at the bottom); set
"crop": trueso the critic knows it is on purpose. - No faces, no hands. People appear only as faceless pictograms (
crowd,isotype,person,people). Do not draw real people; draw an object that stands for them. - Scale contrast. Giant object with small people, or a big panel with small stickers.
- Rhythm. Waves, glyph fields and pictogram rows fill empty space.
- Pick an idea first. Before drawing, write three object metaphors for the story ("a dumbbell whose weights are hearts") and keep the sharpest. Alone, a heart, bulb, gear, globe, handshake or rocket is a cliché.
Formats and reflow#
format / canvas set the canvas; the frame, filters and critic follow it. A scene whose coordinates are written for another size simply sets format and uses its own coordinates. To reuse a 1200×673 scene on another canvas set "reflow": true (or levni render scene.json out.png --format story). It is a recomposition, not a crop:
- Grounds stretch. Full-bleed elements (
panel,glyphs,waves,halftone,flowfield,hatch,confettispanning at least 80 % of the width or height, andhills) andclipare stretched to the new canvas. Hills stay on the bottom edge and keep their proportions. A radialglyphsglow follows the moved objects. - Everything else is one object cluster. Its internal layout and relative positions are kept; it scales by
min(sx, sy)(never distorted, never cropped: it is shrunk further if it does not fit), and keeps ink widths and the hand look. - Placement. Wide canvases (
og,youtube) keep the cluster's relative position. Square and tall canvases centre it in the free area; on a tall canvas (story) that area is the upper part (top 10 % and bottom 26 % kept clear of app bars and for the title). - Title-aware. With a
title, the free area excludes the title block or band (plus a gap), so objects never sit under the text.
Limits: a cluster that is wide and shallow leaves empty ground above and below on tall canvases (it is not re-spread); objects that sit on a ground edge on purpose (a crowd at the panel's bottom, crop: true bleeds) float or end short after scaling; marks and small satellites move with the cluster and can end close to the edge. For those scenes author the tall version directly ("format": "story" with its own coordinates). Cost: a reflow composes twice (measure, then draw).
Title layer#
{ "title": { "text": "Why every newsroom wants a data desk", "kicker": "Analysis", "position": "bottom",
"font": "serif", "brand": "levni.dev", "band": "blue", "color": "paper" } }
| field | meaning |
|---|---|
text |
the headline; word-wrapped, at most 3 lines (an ellipsis if it still does not fit), the largest font size that fits |
position |
bottom (default), top, left (a column, ~42 % of the width), band (a full-width colour band at the bottom, blue unless band is set) |
font |
serif (Georgia), sans (Helvetica Neue), mono (Menlo), or { "file": "/path/font.ttf" } (also .otf, .woff, .woff2; optional width per-em character width, default 0.6) |
kicker |
small upper-case mono line above the title |
brand |
small mono line below it, e.g. levni.dev |
color, kickerColor |
text colours (names or #rrggbb); default ink on light grounds, paper on dark grounds or bands |
band |
colour of a backing band (full width for top/bottom, a column for left) |
The title is plain SVG text above everything, outside the crayon filter, with safe margins (about 5.5 % of the short side; on story also 10 % at the top and 14 % at the bottom for app bars). Without a band the text gets a thin halo in the background colour; on dark art use band or color. Line breaks come from an approximate character-width model (average width per family), so exotic fonts may need width. No font is shipped: the stacks use fonts most systems have. A font.file is embedded as a base64 @font-face, which browsers honour in .svg output; the PNG/WebP rasteriser (sharp/librsvg) uses system fonts and ignores @font-face, so for raster output install the font on the machine.
Slots (fusion)#
A prop can name places inside its own 0..100 box where something else belongs: a TV has a screen, a magnifier a lens, a trophy a top. Another element can then be put in that slot; Levni positions and scales it, whatever the host's x, y, size, flip and rot.
{ "type": "prop", "id": "tv1", "name": "old-crt-tv-long-shadow", "x": 460, "y": 340, "size": 520 },
{ "type": "prop", "name": "chart-board", "in": { "ref": "tv1", "slot": "screen" }, "fit": 0.92 }
- Host. Give the host an
id(any string on any element), or skip it and use"in": { "prop": "radio", "slot": "dial" }, which means the most recent earlier element of that prop name. The child must come after the host inelements(it is drawn on top). - Rect slots
[x, y, w, h]are areas to fill. Apropordrawchild is scaled to fit inside (its visible ink, aspect kept) and centred;fitis the fill factor, default0.9(above 1 lets it overflow).iconis centred at the largest square that fits;labelis centred and sized to the slot unlesssizeis set;glyphsandpanelgetx, y, w, hfrom the slot. A fifth number tilts a rect slot (degrees, e.g. a credit card's number line). - Point slots
[x, y]are places where something stands. The child's bottom-centre lands on the point; its size is its ownsize(default 30 % of the host), timesfitwhen given.labelis centred on the point. - Children:
prop,draw,icon,glyphs,label,panel. Their ownx,yare ignored;dx,dynudge the result in pixels;rotadds to the host's rotation;flipis the child's own. - A host can be a child too: put a TV in a TV by giving the inner one an
idand anin. - Errors. An unknown slot lists the host's slots (
host "phone" has no slot "lens". Available slots: screen (rect)); an unknownreflists the earlier ids; a host variant without slots says so. - Authoring slots. Add
"slots": { "screen": [22, 23, 60, 36], "top": [50, 8] }to a prop variant (any variant, coordinates in its 0..100 box, all inside 0..100;npm testchecks this). To check the numbers, draw the host with a translucent rect on each slot and look at it. 64 library props have slots on their first variant: monitor, old-crt-tv-long-shadow, mini-flat-screen, tv-face, stage-tv, curtain-tv, falling-ratings-tv, spiral-tv, tv-planter-screen-leaves, tv-apple-antenna, phone, radio, laptop, book, pulse-hand-mirror, door, code-window, shopping-bag, coffee-cup, package, ticket, giant-ticket, warning-sign, dashboard, pill-bottle, stone-suitcase, magnifier, globe, envelope, newspaper, calendar, clapperboard, chart-board, easel, notebook, wallet, credit-card, trophy, trophy-tumbler, briefcase, money-bag, bucket, jug, pitch-deck, paper, stopwatch, clock, film-camera, microphone, lightbulb, sticky-notes, witness-stand-mic, vault-hatch, camera, receipt, map, ballot-box, server-rack, file-cabinet, bench, talk-desk-mic-chat, podium-black-ball, wine-bottle-price-tag, book-stack. Look up a prop's slots inlibrary/props/<name>.json.
Examples: slots-tv, slots-lens.
The critic#
compose() also returns the box of everything it drew; critique(used, canvas) turns that into at most six notes: elements running off the canvas, objects cut by the frame by accident, lopsided weight, no clear focal symbol, icons overlapping. It is cheap and blind to meaning: look at the picture too.
Known limits#
- On a blue panel,
inklines and anoverprintread almost black: usepaperfor lines andcoral/mustardfor the second ink. - For a road in perspective use a thick
line(weight 60–80), not ashape. - To put the sun behind buildings, write the
discbefore theskyline.