Draw a Peano Fractal screenshot

Draw a Peano Fractal

Draw Peano's space-filling curve from its two-placeholder L-system at 90 degrees, capped at depth four.

Privacy First
0 Runs
Updated 2026-11-06
No upload
Runs in this tab

The first space-filling curve

Peano's 1890 curve was the first continuous curve shown to fill a square. The page uses its L-system form: two placeholders X and Y expand into more of the pattern, only F draws a stroke, and every turn is a right angle. The rewrite multiplies the stroke count by about eight per step, which is why depth four already fills the square densely.

Depth is capped at four. The count is 9^n - 1, so depth five is 59,048 strokes, built in a single pass before anything appears, and the canvas cannot resolve the difference. Keeping the cap at four is what makes the page feel immediate rather than stalled.

The axiom is the single symbol X and there is no randomness in the rewrite. The same depth always prints the same path, and the drawing never leaves the browser tab.

Draw a Peano curve from a three-symbol rewrite on a square grid, where only F draws and X and Y expand into more of the pattern.

Depth 0 is a single stroke and depth 4 already fills the square, because the drawing symbols multiply at every level.

How to use it

Set the depth, then press Draw or Animate. Stop ends the animation, and the status line names the stroke count at the depth drawn.

The rule

The rewrite keeps one drawing symbol and two placeholders; the placeholders expand into more of the pattern and never draw on their own. That is why a low depth looks sparse and a high one looks solid.

Where it stops

Depth is capped at 4, because the placeholders multiply each step and depth 5 would be 59,048 strokes — more than the canvas resolves. There is no export and no seed.

What to Expect

Best for

  • seeing a space-filling curve fill a square
  • comparing the effect of placeholders against drawing symbols

What this tool keeps

  • The rewrite and the drawing happen in this tab, so the page works offline and keeps no image.

Frequently asked questions

Why does depth 0 draw only one stroke?

Because only F draws, and X and Y expand into more symbols without drawing. At depth 0 there is one F, so there is one stroke.

Why is the cap at 4?

Because the placeholders multiply at each step: depth 5 would be 59,048 strokes, which is more than the canvas resolves.

Can I change the axiom?

No. The axiom and the production rules are fixed by the construction; the depth is the only control.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.