Every scene key, value, form and field node with its parameters and defaults, plus the ref names, ease curves, fonts and limits.
Reference · 12 min read
This page lists the whole scene language. Write a pattern teaches it step by step. The tables come from the spec tables in dot-matrix-scene.ts, so they list every node.
Scene keys
| Key | Type | Default | What it does |
|---|---|---|---|
duration | number | required | One loop at speed 1, in milliseconds, from 100 to 30,000 |
light | field | required | How bright each dot is, from 0 to 1 |
scale | field | none | The size of each dot: 0 hides it, 1 is 1.6 times the normal size. A dot with no scale is normal size |
angle | field | none | The turn of each dot: 1 is a full turn. Shows on dots that are not round |
tint | field | none | The place of each dot in the palette (look.colors): 0 is the first color, 1 the last |
once | boolean | false | Play one time and hold the last frame |
outcome | "success" or "failure" | none | What a screen reader hears: "Done" or "Something went wrong" |
input | number | none | Bake the value prop in this many steps, from 2 to 65. Without it, the scene ignores value |
most | number | 9 | The most dots along the height that the scene reads well at, from 3 to 64 |
How nodes work
- A value is a plain number, or an object with
fn. It gives a number for each dot at each time. - A form is an object with
form. It gives a shape, as a distance to its edge: below 0 is inside. - A field is an object with
op. It gives the light of each dot, from 0 to 1. - Every parameter of kind "value" takes a number or a value node. So any number can change over time.
- A "plain number" parameter takes only a number. It is fixed for the whole loop.
The space runs from -1 to 1 along the longer side of the lattice, with 0 in the middle. x grows to the right and y grows down. Angles are in radians: 0 is the top, and angles grow clockwise. One dot is unit wide.
Values
Each node has the key fn with its name.
| Node | What it does | Parameters |
|---|---|---|
keys | Keyframes over the loop. Holds the first value before the first stop and the last after the last. | stops: [t, value] pairs. t rises from 0 to 1; ease (optional): ease name. The curve between stops. Default inOut |
spin | An angle in radians: t × 2π × turns + offset. | turns: plain number. Full turns in one loop. Negative turns the other way; offset (optional): value. Added angle, in radians. Default 0 |
pulse | Goes from low to high and back, on a cosine. | low: value. The value at the start; high: value. The value at the middle; beats (optional): plain number. Round trips in one loop. Default 1; phase (optional): value. Shift, as a part of a beat. Default 0 |
ref | Reads the time, the dot or the copy. See the ref table. | name: ref name. One of the ref names |
add | The sum of all items. | of: list of values. The items |
mul | The product of all items. | of: list of values. The items |
min | The smallest item. | of: list of values. The items |
max | The largest item. | of: list of values. The items |
sub | a − b. | a: value; b: value |
div | a ÷ b. Gives 0 when b is 0. | a: value; b: value |
pow | ` | a |
mod | a wrapped into 0 to b. Gives 0 when b is 0. | a: value; b: value |
sin | Sine of an angle in radians. | of: value |
cos | Cosine of an angle in radians. | of: value |
abs | The value without its sign. | of: value |
exp | e to the power of the value. | of: value |
floor | The value rounded down. | of: value |
clamp | The value held between 0 and 1. | of: value |
hash | A fixed random number from 0 to 1 for the value. Same on the server and in the browser. | of: value |
mix | from + (to − from) × k. | from: value; to: value; k: value. 0 gives from, 1 gives to |
smooth | A smooth step from 0 to 1 as of goes from from to to. | from: value; to: value; of: value |
ease | An ease curve applied to a value held to 0 to 1. | name: ease name. An ease name; of: value |
noise | Smooth noise in 3D, from 0 to 1. Use z as time. | x: value; y: value; z: value; period (optional): plain number. z wraps at this number, so a loop that runs z from 0 to period joins. Default 0 (no wrap) |
Ref names
{ "fn": "ref", "name": "t" } reads one of these:
| Name | What it reads |
|---|---|
t | Time in the loop, from 0 to 1 |
input | The value prop, from 0 to 1. Needs the scene key input |
u, v | The dot's place, from -1 to 1 along the longer side |
r | The dot's distance from the middle |
angle | The dot's angle, from 0 to 2π, 0 at the top and clockwise |
width, height | Half the width and half the height of the lattice. The longer one is 1 |
unit | The distance from one dot to the next |
index | The dot's number, in row order |
col, row | The dot's grid column and row, from 0 |
i, count, seed | Inside repeat or particles: the copy number from 0, the number of copies, and a fixed random number from 0 to 1 for the copy |
Ease names
An ease parameter takes one of these curves:
| Name | Curve |
|---|---|
linear | Even speed |
in | Starts slow (cubic) |
out | Ends slow (cubic) |
inOut | Starts and ends slow (cubic). The default of keys |
sine | A soft start and end |
outBack | Goes past the end, then settles |
spring | Rings past the end a few times, then settles |
Forms
Each node has the key form with its name.
| Node | What it does | Parameters |
|---|---|---|
circle | A disc at the middle. | radius: value |
box | A box at the middle, with round corners. | w: value. Half the width; h: value. Half the height; r (optional): value. Corner radius. Default 0 |
segment | A line from one point to another, with round ends. | x1: value; y1: value; x2: value; y2: value; width: value. The full width of the line |
polyline | A line through points. | points: [x, y] pairs. Up to 256 points; width: value. The full width of the line; upTo (optional): value. How much of the line shows, 0 to 1. Keyframe it to draw the line. Default 1 |
dot | A disc that moves along a path. | radius: value; along: [x, y] pairs. The path, up to 256 points; at: value. Where on the path, 0 to 1. It wraps; closed (optional): true or false. The path goes back to its first point. Default false; stretch (optional): true or false. Points run from -1 to 1 and stretch to the lattice box. Default false |
arc | Part of a ring, with round ends. | radius: value; start: value. The middle of the arc, in radians. 0 is the top, and angles go clockwise; sweep: value. The length, in radians; width: value. The full width of the stroke |
polygon | A regular polygon with a corner at the top. | sides: plain number. 3 to 32; radius: value. The distance to a corner |
star | A star with a tip at the top. | tips: plain number. 2 to 32; radius: value. The distance to a tip; depth (optional): value. The inner radius, as a part of radius. Default 0.45 |
cross | A plus sign. Turn it with place for an ×. | size: value. Half the length of an arm; width: value. The full width of an arm |
union | All the forms together. | of: list of forms |
smoothUnion | All the forms, melted together like blobs. | of: list of forms; k: value. How soft the joins are |
subtract | Form a with form b cut out. | a: form; b: form |
morph | A blend from form a to form b. | a: form; b: form; k: value. 0 gives a, 1 gives b |
cycle | Shows each form in turn over the loop and morphs to the next. | of: list of forms; hold (optional): plain number. The part of each turn that holds still before the morph. Default 0.45 |
outline | Only the edge of a form. | of: form; width: value. The full width of the edge |
place | Moves, turns and scales a form. | of: form; x (optional): value. Default 0; y (optional): value. Default 0; angle (optional): value. In radians. Default 0; scale (optional): value. Default 1 |
repeat | Copies a form. Inside, ref reads i, count and seed of each copy. | of: form; count: plain number. 1 to 64 copies |
Fields
Each node has the key op with its name.
| Node | What it does | Parameters |
|---|---|---|
paint | Lights the dots inside a form. | form: form; light (optional): value. The brightness inside. Default 1; glow (optional): plain number. A soft halo outside the form, in dots. Default 0 (none); bold (optional): plain number. Grows the form, in dots, so thin lines read on small grids. Default 0.25 |
light | Sets each dot to a value, held to 0 to 1. | value: value |
trail | Adds older frames of a field, dimmer with age. | of: field; length (optional): plain number. How far back, as a part of the loop. Default 0.12; samples (optional): plain number. Older frames to add, 1 to 16. Default 6 |
brightest | The brightest of the fields at each dot. | of: list of fields |
sum | The fields added, held to 1. | of: list of fields |
gain | A field times a value, held to 0 to 1. | of: field; by: value |
fit | Draws a field in the square of the shorter side, so it keeps its shape on a wide lattice. | of: field |
time | Plays a field at another speed or offset. | of: field; speed (optional): value. Default 1; offset (optional): value. A part of the loop. Default 0 |
sequence | Plays each field in turn. Each one gets an equal part of the loop and plays its own full loop in it. | of: list of fields; blend (optional): plain number. The part of each turn that cross-fades to the next. Default 0.15 |
particles | Discs, one for each copy. Inside, ref reads i, count and seed. | count: plain number. 1 to 64; x: value; y: value; size: value. The radius of each disc; light (optional): value. Default 1 |
sparkle | Random dots that blink on and off. | density (optional): plain number. The part of the dots lit at a time. Default 0.15; speed (optional): plain number. Blinks in one loop, a whole number. Default 2 |
text | Text in a dot font, at the middle, or scrolling right to left. | text: text. Up to 200 characters; font (optional): 5x7 or 3x5. Default 5x7. 3x5 has capitals and numbers only; x (optional): value. Shift in dots. Default 0; y (optional): value. Shift in dots. Default 0; scroll (optional): plain number. Passes across in one loop. Default 0 (still) |
image | A picture, fitted inside the lattice. Bright pixels light the dots. | src: image URL. An image URL. A preset takes only a PNG, JPEG, GIF or WebP data URL; invert (optional): true or false. Dark pixels light the dots. Default false |
frames | A list of pictures, played as frames over the loop. | src: list of image URLs. 1 to 64 image URLs, as for image; invert (optional): true or false. Default false |
life | Conway's Game of Life on a board that wraps at the edges. | seed (optional): plain number. The random start. Default 1; density (optional): plain number. The part of live cells at the start. Default 0.35; steps (optional): plain number. Generations in one loop, 1 to 64. Default 12 |
sand | Sand that pours, piles up and drains. | seed (optional): plain number. Default 1; rate (optional): plain number. Grains for each pour, as a part of the height. Default 0.5 |
flock | A few birds that flock together. | seed (optional): plain number. Default 1; count (optional): plain number. Birds, 1 to 64. Default 6 |
reaction | Gray-Scott reaction-diffusion. | seed (optional): plain number. Default 1; feed (optional): plain number. Default 0.037; kill (optional): plain number. Default 0.06 |
Fonts
The text field draws with a dot font:
| Font | Size | Has |
|---|---|---|
5x7 | 5 × 7 dots | Printable ASCII, and °, •, …, →, ←, ✓, ✗ |
3x5 | 3 × 5 dots | Capitals, numbers and common signs. A small letter shows as its capital |
A character the font does not have shows as ?.
Limits
decodePreset and parsePreset hold every scene to these limits. A scene you write in code is not checked, but the same limits keep it fast.
| Limit | Value |
|---|---|
| Nodes in a scene | 4,000 |
| Nesting depth | 40 |
Items in a list (of of add, union, brightest…) | 1 to 64 |
Copies in repeat or particles | 1 to 64 |
trail samples | 1 to 16 |
polygon sides, star tips | 3 to 32, 2 to 32 |
life steps | 1 to 64 |
| Points or stops in a list | 256 |
text | 200 characters |
| Other plain numbers | -1,000,000 to 1,000,000 |
| An image | 600,000 characters, as a PNG, JPEG, GIF or WebP data URL |
Frames of frames | 1 to 64 |