Case study · Tool
Plate
The engine that draws every image on this site from code, in your browser.
- Year
- 2026
- Role
- Design and build
- Status
- Live on this site, and open source
- Built with
- TypeScript, Canvas, WebGL, React
Plate is the small engine that draws every image on this site. Each picture, from the sunflower to the moon, is a short program that runs in your browser. The result is then reduced to the same three tones of ink, a technique called dithering, so that it looks like a printed engraving.
I wanted the site to look printed rather than built from a template, without making visitors download heavy images. It also had to stay quick on a phone.
Each plate is a generator with a simple rule behind it. One places seeds at the golden angle, one grows a fern from four rules, one branches a tree, and one draws the moon in tonight’s phase. Plates are built one at a time and the dithering runs on the graphics card, so the page does not stall while it loads. Sharing one three-tone palette is what lets such different subjects sit together as a set.
Because the art is code rather than pictures, the whole site stays small, and adding a new plate takes about an afternoon. The engine is now a library of its own, plate-engine, published on npm with no dependencies, and its tests check that it still draws this site’s plates exactly. Plate Studio puts it in a browser tab: choose a generator or drop in a picture, pick a dither and a palette, and download the result. Your picture never leaves your device.
I designed and built the engine and the site that uses it. The art direction turned out to be part of the engineering: choosing three tones and sticking to them did more for the look than any single drawing. Below, a short film shows three plates being drawn step by step, and an essay explains the rules behind them.
The film · Visual essay
Engravings, drawn live
A fern, a sunflower and the moon, each drawn from its rules, one step at a time. One minute and forty-six seconds, silent, with captions.
- Film
- 23 October 2026
- Length
- 1 min 46 s, silent
- Licence
- CC BY 4.0
What you are watching
Three plates, each drawn by a program from a few rules, shown while the rule runs.
The fern is Barnsley’s: four affine maps and a loaded die. The film plots the first points one at a time, with the chosen map lit in the readout, then speeds up until 334,176 points have landed and the fern is there.
The sunflower is Vogel’s model: each seed turns 137.508 degrees from the last and steps out a little. The first seeds go down one by one, then the rest, 619 in all. Then the angle changes to 135 degrees, which makes eight straight rows, and to 137, which tears the head into arms, before going back.
The moon is engraved row by row under full light, then the light turns to where it was at midnight UTC on 23 October 2026: about 139 degrees from the sun, 88% lit, waxing gibbous. The dark side is drawn faint so the face stays legible. The seas are placed by hand and the craters at random. The light is the only part that follows a rule, and the film says so.
How it was made
Every frame is drawn in a browser running without a window, by the same code that draws the plates on this site, plate-engine, and reduced to the site’s three tones of ink, a technique called dithering. A script renders the frames one at a time, at 30 per second, and hands them to FFmpeg, which encodes this version, a WebM for the page, and a vertical cut. Nothing is filmed and nothing is drawn by hand.
The render is deterministic. The script records a fingerprint of every frame (a SHA-256 hash). Its end-to-end test renders two stretches from the middle of the film twice and checks every frame comes out byte for byte the same, and, when a full render is present, that the stretches match it frame for frame. The finished fern and sunflower are tested cell for cell against plate-engine’s own plates.
The film is silent. The captions are part of the picture and are also in the captions track, from the same script.
Credits
Type: Big Shoulders Display and Geist Mono, both under the SIL Open Font License. No music, no images, no footage: everything on screen is computed. The film, its stills and captions are CC BY 4.0; the code is MIT.
The essay
Four rules and a fern
A whole fern comes out of four small rules and a die. A sunflower comes out of one angle. Where does the complexity come from, if not from the rules?
- Essay
- 23 October 2026
- Figures
- Live, drawn with plate-engine
- Licence
- CC BY 4.0
A plant from a die
Here is a way to draw a fern. Put a point on a page. Roll a die. Depending on the roll, move the point by one of four rules, and mark where it lands. Roll again and move the new point. Do this sixty thousand times.
A fern appears. Not a picture someone drew and the dots filled in. The dots are the fern. Nothing in the four rules mentions a leaflet, a stalk or the curl at the tip. Each rule only says how to shrink, turn and shift a point.
This site’s plates are drawn from rules like these: the fern, a sunflower head, a branching tree, all made by small programs rather than by hand. This essay follows those three plants and asks a plain question. If the rules are this short, where does the complexity come from?
The figures below are live. Each one is drawn by plate-engine, the library behind the site’s plates, and each has a slider for the one rule it is about. Change it and the plant redraws. Breaking the plants turns out to be the quickest way to see what each rule is doing.
Four maps
Each of the four rules is an affine map: the new x is a·x + b·y + e, the new y is c·x + d·y + f. A map like this can shrink a shape, turn it, slant it, flip it and move it, and straight lines stay straight. The fern is four such maps, six numbers each, from Michael Barnsley’s book Fractals Everywhere.
The frond map shrinks everything to 85% of its size, turns it about three degrees, and lifts it 1.6 units. The left leaflet map shrinks to roughly a third and turns about fifty degrees. The right leaflet map shrinks to roughly a third and flips the shape over, so its leaflet faces the other way. The stem map does something drastic: it squashes the whole plane onto a short vertical line, 16% as tall.
Now the trick. Apply the frond map to the finished fern and you get the same fern, slightly smaller, standing on top of the first piece of stalk. Apply the leaflet maps and you get the two lowest leaflets. Apply the stem map and you get that first piece of stalk. The four pieces together are the fern again. The fern is exactly four smaller copies of itself.
That is why it looks like a fern all the way down. Each leaflet is a copy of the whole fern, so each leaflet has leaflets, and so on until they are smaller than the dots used to draw them. Shapes built from smaller copies of themselves like this are called fractals.
There is a theorem behind this. In 1981 John Hutchinson showed that any finite set of maps that each pull points closer together has exactly one shape that equals the union of its own copies under those maps. So the four maps do not suggest a fern. They define one, completely. In 1985 Barnsley and Stephen Demko called such sets of maps iterated function systems and showed how to draw the shapes they define.
The chaos game
A shape defined as “the thing equal to four copies of itself” sounds hard to draw. One way is to start with any picture at all, apply all four maps, keep the four copies, and repeat. The picture converges on the fern whatever you start with. But the number of pieces multiplies by four each round, and after ten rounds there are more than a million.
The other way is the one the die is for, usually called the chaos game. Keep a single point. At each step, choose one map at random and move the point with it. Plot every position.
It works because every map shrinks distances. The frond map shrinks least, by a factor of 0.851. So whatever the starting point, after 20 steps it is at most 4% of its starting distance away from the fern, and the next steps only bring it closer. The figure throws away those first 20 points and keeps the rest. From then on the point wanders over the fern and never leaves it.
In 1987 John Elton proved what makes this trustworthy: over a long run, the share of time the point spends in each part of the fern settles to one fixed pattern, whatever the starting point, for all but a vanishingly unlucky run of the die.
Why the weights matter
The die is loaded. Barnsley’s weights pick the frond map 85 times in 100, each leaflet map 7 times, and the stem map once. Here is the fern with those weights, and with sliders for all four.

- Stem
- 1.0%
- Frond
- 85.0%
- Left leaflet
- 7.0%
- Right leaflet
- 7.0%
Shape and ink
The maps decide the shape. The weights only decide where the ink goes. As long as every weight is above zero, the point visits every part of the fern eventually. But eventually is the catch, and ink is all you can see.
Press Equal weights. Same maps, same 60,000 points. The bottom of the plant is thick, and the top barely exists. In numbers: Barnsley’s weights ink 13,358 cells of this plate, 48% of them in its upper half. Equal weights ink 1,866 cells, and 9% are in the upper half.
The reason is in the climb. Each frond step moves the point one rung up the fern, so reaching the tip takes the frond map many times in a row. With Barnsley’s weights, ten frond steps in a row happen about one time in five. With equal weights, about one time in a million. The upper fern is there, in the mathematics. The dots just almost never get to it.
There is a sensible way to load the die: give each map a share in proportion to how much area it keeps, which is the absolute value of its determinant, ad − bc. The frond keeps 72% of the area, the leaflets about 10% and 11%. Shared out, that is 77, 11 and 12, and nothing at all for the stem, which flattens everything to a line and so keeps no area. With a weight of zero the stalk would never be drawn. Barnsley’s 85, 7, 7 and 1 lean further towards the frond and keep a little for the stem. Paul Bourke’s notes on the fern, dated 1988, put it simply: with the right probabilities it emerges much faster and more evenly than with equal chances.
Now set one weight to zero. With the left leaflet at zero, the left leaflets do not just lose the bottom one. They vanish at every scale, on every frond, because every left leaflet anywhere is made by that one map. With the stem at zero, every stalk disappears and the leaflets float. A rule in this system is never local. Everything it touches, it touches everywhere.
One angle
A sunflower head is another plant that looks complicated and is not. The seeds sit in two families of spirals, one turning each way. Count the spirals in one family and the number is usually a Fibonacci number: 21, 34, 55 and so on.
In 1979 Helmut Vogel described a model that draws such a head with one rule. Seed number n sits at an angle of n times 137.508 degrees, at a distance from the centre that grows as the square root of n. The square root keeps the seeds evenly spread: the area of a disc grows as the square of its radius, so each new seed gets the same share of room. The angle does everything else.

- Turn per seed
- 137.508°
- Share of a full turn
- 0.38197
Why 137.5 degrees
Press 135°. That is three eighths of a full turn, so every eighth seed comes back to the same direction, and the head collapses into eight straight spokes with empty wedges between them. 144° is two fifths of a turn and makes five spokes. Any angle that is a simple fraction p/q of a turn gives q spokes.
Press 137°. It is not a simple fraction, but it is close to several, and the seeds nearly line up: they curl into arms with wide gaps between them. Half a degree from the golden angle, the head is already torn open.
The golden angle is 0.381966 of a full turn, which is one over the golden ratio squared. Its special property is that it is as far from every simple fraction as a number can be: Adolf Hurwitz proved in 1891 that no number is harder to approximate by fractions than the golden ratio and the numbers built from it like this one. Written as a continued fraction it is 0; 2, 1, 1, 1, and ones forever after, and its best approximations by fractions are 1/2, 1/3, 2/5, 3/8, 5/13, 8/21, 13/34, 21/55: ratios of Fibonacci numbers, each a little better than the last and none ever exact.
That explains both halves of the picture. Because no fraction is exact, no two seeds ever line up on the same ray, and there are no wedges and no wasted space. Because those Fibonacci fractions are each nearly right for a while, the eye picks out near-spokes that curve into spirals, and the spirals you count come in Fibonacci numbers. Near the centre one fraction is the best fit, further out the next one is, which is why the count changes as you move outwards.
What the plant actually does
Vogel’s model describes a sunflower. It does not explain one. A sunflower does not measure angles.
In 1992 Stéphane Douady and Yves Couder showed how an angle like this can arise with nobody measuring it. They let drops of magnetic fluid fall one at a time onto the centre of a dish of oil in a magnetic field. Each drop was pushed away from the centre and repelled the drops before it, so each new drop went where there was most room. Depending on how fast the drops came, the pattern settled into spirals at the golden angle or into other arrangements. The golden angle was not in the rule. It came out of it.
Plants have a mechanism of the same shape. In 2003 Didier Reinhardt and colleagues showed that in a growing shoot tip, the plant hormone auxin is pumped towards points where it builds up, and a new leaf or floret forms where it does. Each young organ drains auxin from around it, so the next one can only start in the gap. Inhibition by neighbours, like the drops.
And real sunflowers are not perfect. In a 2016 citizen science study, Jonathan Swinton, Erinma Ochu and the MSI Turing’s Sunflower Consortium counted spirals on 657 sunflowers. In their most reliable data, 565 of 768 spiral counts were Fibonacci numbers and another 67 had a Fibonacci structure of a predefined kind. The other 136 did not, and some heads had no clear count at all. The rule is a good description. It is not a law.
Rewriting
The third plant on the site’s plates is a branching tree, and the third kind of rule is the oldest of the three. In 1968 the biologist Aristid Lindenmayer published rules for how strings of cells develop, each cell replaced at each step according to its state. These are now called L-systems. In The Algorithmic Beauty of Plants (1990), Przemysław Prusinkiewicz and Lindenmayer read the strings as drawing instructions for a turtle: F means draw a line forward, + and − mean turn by a fixed angle, [ means remember where you are, ] means go back there. The brackets let a branch grow and the drawing return to where it forked.
The figure below uses one of the book’s examples. Start with X, a bud that draws nothing. At each step, replace every X with F[+X]F[−X]+X and every F with FF. After one rewrite that is a stalk with a bud to the left, a bud to the right and a bud at the tip. At the next, every bud becomes the same pattern, and every piece of stalk doubles in length, so the trunk keeps lengthening while the tips branch.
![A bush drawn by seven rewrites of the bracketed L-system X → F[+X]F[−X]+X, F → FF, at 20 degrees.](/writing/four-rules-and-a-fern/fig-lsystem.png)
- Rewrites
- 7
- Branch angle
- 20°
- Symbols
- 13,956
- Line segments
- 4,118
Growth by rewriting
The rule for a bud is 12 symbols long, so after one rewrite the string is 12 symbols and draws 2 lines. After seven it is 13,956 symbols and draws 4,118 lines, roughly three times more at every step, because every bud becomes three buds.
The angle slider shows how little the rule cares about the angle. At 20° the book’s bush. Wider and it sprawls; narrower and it closes into a broom. The branching, the proportions and the way the old wood lengthens all stay the same, because they are in the rewriting, not in the angle.
Where the complexity comes from
Three plants, three kinds of rule: four maps chosen at random, one angle repeated, one rewrite applied to every bud at once. In each case the rule is short, and the complexity is in the repetition. A small rule is applied to its own output again and again, and every application leaves something behind.
The fern and the bush are copies of themselves at smaller scales, by construction. The sunflower is not. Its complexity comes from a different place: an angle that can never be written as a fraction, used on a finite number of seeds.
It would be easy to stop there and say that nature runs on simple rules. That is not what these figures show. Each rule was written after looking at a plant. Barnsley chose numbers that look like a fern, Vogel wrote a rule that draws a sunflower, and the L-system was chosen because it draws a convincing bush. A rule that reproduces a form is not evidence that the form grew that way. Ferns do not play the chaos game. The link from the sunflower’s rule to a cause comes from separate experiments, with drops of fluid and with a plant hormone, not from the drawing.
What the figures do show is how much a short rule can carry, and how fragile that is. Give the four rules equal weights and most of the fern goes missing. Move the angle half a degree and the sunflower tears open. Set one weight to zero and a part of the plant vanishes at every scale at once. When a result looks complicated, look for the short rule under it, and then test the rule by changing it. The sliders are that test.
The film above shows the fern, the sunflower and the moon being drawn from their rules, one step at a time.
Sources
Show sources (13)
M. F. Barnsley, Fractals Everywhere, 2nd ed., Academic Press, 1993. The fern’s four maps and weights as given there, checked against two independent reproductions of the table: Brown University course notes (dam.brown.edu/people/mchb/la/fractals.pdf) and the Wikipedia article “Barnsley fern”.
J. E. Hutchinson, “Fractals and self similarity”, Indiana University Mathematics Journal 30 (1981) 713–747, doi:10.1512/iumj.1981.30.30055.
M. F. Barnsley and S. Demko, “Iterated function systems and the global construction of fractals”, Proceedings of the Royal Society of London A 399 (1985) 243–275, doi:10.1098/rspa.1985.0057.
J. H. Elton, “An ergodic theorem for iterated maps”, Ergodic Theory and Dynamical Systems 7 (1987) 481–488, doi:10.1017/S0143385700004168.
P. Bourke, “How to create the IFS fern”, paulbourke.net/fractals/ifs/.
A. Hurwitz, “Ueber die angenäherte Darstellung der Irrationalzahlen durch rationale Brüche”, Mathematische Annalen 39 (1891) 279–284, doi:10.1007/BF01206656.
H. Vogel, “A better way to construct the sunflower head”, Mathematical Biosciences 44 (1979) 179–189, doi:10.1016/0025-5564(79)90080-4.
S. Douady and Y. Couder, “Phyllotaxis as a physical self-organized growth process”, Physical Review Letters 68 (1992) 2098–2101, doi:10.1103/PhysRevLett.68.2098.
D. Reinhardt et al., “Regulation of phyllotaxis by polar auxin transport”, Nature 426 (2003) 255–260, doi:10.1038/nature02081.
J. Swinton, E. Ochu and the MSI Turing’s Sunflower Consortium, “Novel Fibonacci and non-Fibonacci structure in the sunflower: results of a citizen science experiment”, Royal Society Open Science 3 (2016) 160091, doi:10.1098/rsos.160091.
A. Lindenmayer, “Mathematical models for cellular interactions in development I. Filaments with one-sided inputs”, Journal of Theoretical Biology 18 (1968) 280–299, doi:10.1016/0022-5193(68)90079-9.
P. Prusinkiewicz and A. Lindenmayer, The Algorithmic Beauty of Plants, Springer, 1990, doi:10.1007/978-1-4613-8476-2. Free edition at algorithmicbotany.org/papers/#abop.
Every number in this essay is computed by the code that draws its figures (scripts/four-rules-numbers.ts in this site’s source).