← Home

How the plant grows

The plant beside my name is grown from the commit the site was built from. A small seeded branching algorithm turns the commit hash into an SVG, so every deploy grows a new plant, and the same commit always grows the same one.

Commit 9a91ee4
Commit 8952782
Commit d3b041f
Three plants grown from earlier commits of this site.

From commit to seed

The build reads its own commit, hashes it with FNV-1a into a 32-bit number, and seeds mulberry32, a tiny pseudo-random generator, with it. Every random choice below comes from that generator in a fixed order, which is why a commit always grows the same plant.

Branching

  • The trunk starts at the bottom centre of a 320 × 380 frame, leaning up to about 7° off vertical.
  • Each stem is a quadratic curve that bends up to about 20° along its length.
  • At its end a stem splits into one to three shorter stems, each 68–86% as long. The trunk and its first limbs always split in two, so no plant comes out bare.
  • Every new stem is pulled 15% of the way back toward vertical, which keeps the plant upright.
  • A stem stops splitting five levels up, when it is shorter than 14 units, or once the plant has 48 stems, and it ends in a leaf.
  • The middle stems sprout one or two leaves on alternating sides, in one of three greens.

Fitting the frame

A tall seed can grow past the edges. The generator shrinks the plant about its base, 3% at a time, until every stem fits and every leaf has a full leaf's length of room, then slides it sideways if one side still pokes out.

Drawing it in

Each stem and leaf records when it grew. Stems draw themselves along their length and leaves fade in, a generation every 0.11 s, so the whole plant is in after about 1.2 s. It is plain CSS, and it runs only for visitors whose system allows motion; everyone else sees the grown plant.

Tests

The plant is built into the HTML, so the page loads no JavaScript for it. Tests grow 300 plants and check that each one stays inside its frame, weighs at most 15 KB (they run about 6 to 12 KB), and has at least 24 leaves, and that 20 seeds grow 20 different plants.