SfcSpace-Filling Curve

Mathematical & Geometric · Scale 4

Space-Filling Curve

One unbroken line that visits every cell of a grid once and never crosses itself. The one we draw is the Hilbert curve.

What it is

A space-filling curve is a single unbroken line that visits every cell of a grid exactly once and never crosses itself. The Hilbert curve does this on a square grid whose side is a power of two: 4 by 4, 8 by 8, 16 by 16 and so on.

It is built by repetition. Start with a U shape. Replace each of its four corners with a smaller U, turned to fit. Do the same to the result. Each level joins four copies of the one before, and the number of levels is the depth.

The plates

Five plates, at depths 2 to 6. Depth 2 visits a 4 by 4 grid and depth 6 a 64 by 64 grid. The line is cut where it crosses the outline of the word, and the parts inside the word are drawn heavier.

Safari stop · One line · Depth
  • depth 2

  • depth 3

  • depth 4

  • depth 5

  • depth 6

Turn the dial on the safari →

The plates are drawn by mosaic, a small Python library of our own, built on numpy, scipy, shapely and contourpy. No image model is involved, and each plate is a flat-colour SVG under 45 KB. The word Ciao is the safari's constant: it sits in the same place on every plate.

What we did and found

Our code maps an index straight to a cell: give it a position along the line and it returns the cell at that position. It is 15 lines, and it placed 1,048,576 points in 0.1 s.

The same curve can also be written as a rewriting rule and drawn by a turtle. That is the L-system cell. See the L-system cell →

What is open

Only the Hilbert curve is drawn, and the plates stop at depth 6.

mosaic is not yet part of Platypus, our visuals engine. That is why this cell is marked as working and not as shipped: the page is our notebook on the element.

Composes with

Other cells in the table — most still to be walked into in coming sessions.