Pick where the dots sit with 7 named layouts or your own grid, how many dots fit a size, and which of 9 dot shapes to draw.
Engine · 3 min read
A layout is the set of places where dots can light. We call it a lattice. The same pattern runs on any lattice, so you can change the outline and keep the movement.
Named layouts
For n dots along the height, each layout makes this grid:
lattice | Shape | Grid |
|---|---|---|
square (default) | A full square of dots | n × n |
circle | A round panel | n × n, cut to a circle |
rounded | A square with soft corners | n × n, cut to a rounded square |
ring | A circle with an empty middle | n × n, cut to a ring half as wide as the circle |
capsule | A pill, about twice as wide as it is tall | 2n + 1 × n, cut to a pill |
bar | A strip three times as wide as it is tall | 3n × n |
hex | Rows offset by half a dot, packed as a honeycomb | n × n + 2, cut to a circle |
Your own grid
Pass an object for any number of columns and rows. A preset allows up to 64 of each.
| Key | Type | Default | What it does |
|---|---|---|---|
cols | number | required | Dots across |
rows | number | required | Dots down |
mask | rect, circle, rounded, capsule or ring | rect | The outline. A dot stays when its middle is inside it |
hex | boolean | false | Shifts every other row by half a dot and packs the rows closer: a honeycomb |
Your own grid is fixed: size and look.grid do not change its number of dots. The dots get smaller as the grid grows.
<DotMatrix pattern="marquee" lattice={{ cols: 31, rows: 7 }} size={28} />How many dots
size is the height in CSS pixels. The width follows from the lattice. The engine picks the number of dots along the height for you:
- It keeps the dots at least 4px apart. Closer than that, a dot and its gap merge and the pattern reads as noise.
- It never uses more dots than the pattern reads well at (the scene's
most, 9 by default). - It always picks an odd number, so a pattern has a middle dot.
- It never uses fewer than 3.
Set look.grid when you want a fixed number. Fix it when one loader switches between patterns. Then the grid does not change in the middle of a morph.
Dot shapes
look.dot sets how each dot is drawn. round is an LED, square a panel cell, and pixel a soft square. The rest are marks.