Draw Triangle Dragon Fractal

Draw the terdragon (Davis-Knuth 1970) - space-filling triangle dragon, 3-fold symmetry, dim 2.0. Free, offline, client-side, instant, secure.

Renders the terdragon (triangle dragon curve, Davis & Knuth 1970) via L-system axiom F, rule F → F+F-F, 120° turns. The terdragon is space-filling with similarity dimension log(3)/log(√3) = 2.0.

How to Use Draw Triangle Dragon Fractal

  1. Pick iterations (1-10). Each iteration triples the segment count: iter 7 = 2,187; iter 10 = 59,049.
  2. Set segment length (1-20 px). The tool auto-scales the whole curve to fit the canvas regardless.
  3. Set angle (1°-179°). 120° gives the canonical terdragon; other angles give non-canonical experimental figures (clearly labeled in the stats line).
  4. Pick a color, or enable rainbow gradient to color each segment by its position along the traversal.
  5. Optionally enable vertices to dot every junction point (useful for low iterations).
  6. Click Draw Fractal or press Ctrl/Cmd + Enter. Iter 9+ shows a non-blocking time estimate toast.
  7. Copy or download the PNG; filename encodes iteration and angle.

Frequently Asked Questions

What is the terdragon?

The terdragon (triangle dragon curve) is a space-filling fractal curve introduced by Chandler Davis and Donald E. Knuth in their 1970 paper “Number representations and dragon curves” (Journal of Recreational Mathematics). It is built from the L-system with axiom F and rule F → F+F-F at 120° turns. An older version of this FAQ called it a “variant of the Heighway dragon” – that is incorrect; the terdragon is its own independent Davis-Knuth construction, distinct from John Heighway’s 1966 dragon curve.

What is the fractal dimension?

The similarity dimension is log(3) divided by log(√3), which equals exactly 2.0. Solve directly: log(3) / log(3 to the 1/2) = log(3) / (0.5 × log(3)) = 2. The terdragon is therefore space-filling: its image in the limit is a closed region of nonzero area. An older version of this FAQ wrote “approximately 1.5850” – that figure is actually log(3)/log(2), the Sierpinski triangle’s dimension, accidentally pasted into the terdragon description. The displayed stats line has always been correct (2.0000); only the FAQ text was wrong, and is now corrected.

What is the L-system?

Axiom F, rewrite rule F → F+F-F, turn angle 120°. F means “draw forward one unit”; + and − mean “turn left/right 120°”. Iterating the rewrite n times produces a string with 3ⁿ F characters; interpreting it as turtle graphics traces the terdragon polyline.

How does 3-fold symmetry work?

The completed curve has 3-fold rotational symmetry: rotating it about its center by 120° yields the same figure. This follows from the symmetric L-system rule (3 forward moves balanced by one + and one − turn) and the 120° angle. The curve tiles the plane in triples – three terdragons fit together at their start point to fill a hexagonal region exactly.

Why does iteration 10 take longer?

Iteration 10 generates 3¹⁰ = 59,049 segments. Each segment is a separate stroke operation (or a separate color in rainbow mode), so the per-segment overhead dominates. On a modern machine it takes 2-4 seconds. For most exploration, iter 6-8 (729 to 6,561 segments) is plenty.

What does the rainbow gradient show?

Each segment is colored by its index in the curve’s traversal order, mapped to a hue from 0° (red, first segment) to 360° (purple, last segment). This reveals how the curve winds through the plane and which sub-regions are visited early vs late.

Why allow non-120° angles?

Only 120° produces the canonical terdragon. Other angles (e.g. 60°, 90°) generate non-canonical figures from the same L-system rule – sometimes interesting, sometimes overlapping into a thick blob. The stats line marks the figure as “non-canonical angle” when you leave 120° so you know you are no longer drawing the named fractal.

Is anything sent to a server?

No. The tool loads three static files (HTML, CSS, JS) and then runs entirely in your browser – L-system expansion, drawing, PNG export, clipboard copy. You can disconnect from the internet after the page loads. No analytics, no tracking, no cookies.

Is this tool free?

Yes – free, unlimited, no signup, no watermark. Use the PNGs in lectures, papers, blog posts, or art freely. Attribution to is appreciated but not required.