Fold a paper strip in half seven times, open every crease to 90 degrees: a dragon.
A strip of 128 paper segments stands on its edge on a cutting mat and is folded in half seven times, one generation of creases at a time, into a springy 128-layer stack. Then all 127 creases open together to right angles, and from above the strip is the Heighway dragon, sitting exactly on the mat's grid. Crease j was made by fold n - v2(j) and turns right or left by the regular paperfolding sequence (shown along the bottom), so the whole strip is plain forward kinematics on its crease angles. Past seven folds paper gives up but the math continues, each order swinging out a mirrored copy about the end point, and finally four dragons turned by quarter turns about one point interlock without overlapping. The walls are perspective-projected, painter-sorted and Lambert shaded front and back, with crease gradients and projected soft shadows.
Try it. Drag the crease angle slider anywhere from flat to dragon to folded shut. Drag the scene to orbit, use the buttons or + and - to change the number of folds (3 to 9), T to jump to the four-dragon tiling, R to replay and Space to pause.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build an animation that unfolds a folded paper strip into the Heighway dragon curve, with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a full-window canvas that stays sharp on high-DPI screens and resizes with the window.
- Model a strip folded in half n times (start with n = 8) as a chain of 2^n unit segments. Crease j (for j from 1 to 2^n - 1) turns right if the odd part of j is 1 mod 4 and left if it is 3 mod 4. That is the regular paperfolding sequence.
- Give every crease the same opening angle theta. Walk the chain: start at the origin heading east, and at each crease turn the heading by plus or minus theta, then step one unit. Draw the result as a polyline, centered and scaled to fit.
- Animate theta from 180 degrees (folded flat) down to 90 degrees and watch the dragon open. Add a slider for theta.
Once that works, make it beautiful:
- Fold it first: animate the creases made by fold 1 (the middle one), then fold 2, and so on, from 0 to nearly 180 degrees one generation at a time. Crease j belongs to fold n minus the number of times 2 divides j.
- Draw it in 3D: stand each segment up as a wall, project the corners with a simple perspective camera that slowly orbits, sort the walls far to near, and shade the front and back faces in two paper colors by their angle to a light.
- Add soft shadows on a dark cutting mat with a unit grid, and show the R and L turn sequence along the bottom.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as showing four dragons turned by quarter turns tiling around a point, continuing past seven folds, or letting me fold the strip with the mouse.