Draw a Heighway (Dragon) Fractal
Draw the Heighway dragon by folding its turn sequence, doubling the segment count per level, capped at depth 14.
A fold, not a formula
The dragon curve is built by folding. Start with a single right turn; at each step append the same sequence reversed and mirrored, joined by one more right turn. Walking that turn list with a turtle at right angles produces the dragon, which touches itself but never crosses. Depth n has exactly 2^n segments, and the whole path fits inside a bounding box roughly two thirds as wide as it is long.
The page rebuilds the turn list for the chosen depth and walks it once per redraw. That is why the depth is capped at 14: the table holds 16,384 turns and is rebuilt on every frame of the animation, so a deeper fold costs more than the extra detail can show on a 640-pixel canvas.
The dragon is not random and has no seed. The same depth always folds to the same curve, and the page uploads nothing while it draws.
Draw the Heighway dragon by folding a strip at right angles, to a depth you set.
Every turn is a right angle and the fold sequence is deterministic, so the same depth always draws the same curve and nothing is uploaded.
How to use it
Set the depth, then press Draw or Animate. Stop ends the animation, and the status line names the segment count at the depth drawn.
The rule
Depth n turns each segment into two, so the segment count doubles at every level. The turn table is rebuilt on every redraw, which is what makes the deepest levels the slow ones.
Where it stops
Depth is capped at 14, where the drawing is 16,384 segments. There is no seed and no colour control: the curve is a pure function of the depth, and no image is exported.
What to Expect
Best for
- seeing a dragon curve at a chosen resolution
- demonstrating a deterministic fold sequence
What this tool keeps
- The fold table and the drawing are built in this tab, so the page works offline and stores nothing.
Frequently asked questions
What rule draws the dragon?
A right-angle fold sequence: every segment becomes two at the next level, with the turns following the paper-folding order. The turn table is rebuilt for the depth you pick.
Why does a deeper level take longer?
Because the segment count doubles per level and the turn table is rebuilt on each redraw. Depth 14 is 16,384 segments, which is where the cap sits.
Is the curve random?
No. There is no seed — the fold sequence is fixed, so the same depth always produces the same curve.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.