Triangle Dragon Fractal
Draw terdragon / triangle dragon fractals with custom iterations, colors, and line width
Generate triangle dragon (terdragon) fractals instantly — set iterations from 1 to 12, pick your line and background colors, adjust stroke width, and download the result as a PNG. Each iteration triples the segment count, so you go from a single line to over half a million connected segments at max depth.
And everything runs in your browser. Nothing gets uploaded.
How It Works
The algorithm starts with a single line and replaces it with three segments at 120-degree angles on each iteration. After all iterations run, it calculates a bounding box, scales everything to fit the canvas, and draws the path in one stroke. Iteration 6 produces 729 segments; iteration 10 hits 59,049. That exponential jump is why cranking the slider past 10 can make your browser think for a second.
Examples
Quick classroom demo
Showing students how a simple replacement rule creates complexity
Iterations: 3
Line color: #6366f1
Background: #ffffff
Line width: 2
27 segments visible
Clear triangular pattern
Students can trace the construction rule
Desktop wallpaper with dark theme
Creating a high-detail fractal as a background image
Iterations: 10
Line color: #22d3ee
Background: #0f172a
Line width: 1
59,049 segments
Dense, intricate space-filling pattern
Cyan on dark slate — perfect contrast
Comparing iteration growth side by side
A math blog post showing how the curve fills space as iterations increase
Render at iterations 4, 6, 8, 10
Same colors for each
Download each as PNG
4 PNGs showing 81 → 729 → 6,561 → 59,049 segments
Visual proof of exponential growth
Space-filling property becomes obvious by iteration 8
Who Uses This
Show students how a simple substitution rule generates infinite complexity — no coding needed.
Export fractal PNGs as texture layers or poster backgrounds with custom color schemes.
Visualize L-system concepts and recursive geometry before writing their own implementations.
Grab clean fractal images for articles about space-filling curves and tiling theory.
Common Mistakes
Iteration 12 means 531,441 line segments. Your browser might freeze for several seconds — or longer on older hardware. Start at 6-8 and work up.
At iteration 9+, segments are tiny. A line width of 5 turns the fractal into a solid blob. Keep it at 1 for high iterations.
A dark blue line on a black background looks like nothing rendered. Make sure your line color actually stands out against the background — the preview updates instantly, so just try it.
Technical Details
- Processing: 100% client-side (HTML5 Canvas API)
- Browser Support: Chrome, Firefox, Safari, Edge
- Max Iterations: 12 (531,441 segments)
- Canvas Size: 800 × 800 pixels
- Export Format: PNG (full canvas resolution)
Frequently Asked Questions
What is a terdragon fractal?
The terdragon (or triangle dragon) is a space-filling curve discovered by Davis and Knuth in 1970. Each iteration replaces every line segment with three new segments at 120-degree angles. After enough iterations, the curve fills a region of the plane — and six copies of it tile the plane perfectly.
How is a terdragon different from a regular dragon curve?
The Heighway dragon curve uses 90-degree turns and replaces each segment with two. The terdragon uses 120-degree turns and replaces each with three. That is why the terdragon has triangular symmetry and three-fold tiling, while the Heighway dragon has square symmetry.
Why does my browser slow down at high iterations?
Segment count grows as 3^n. Iteration 10 draws 59,049 segments, iteration 12 draws 531,441. The browser has to compute coordinates for each segment and render them all on a single canvas stroke. On most machines, anything above 10 takes a noticeable pause.
Can I use the generated fractal images commercially?
Yes. The images you generate are yours. The fractal itself is a mathematical object — you cannot copyright math. Use the PNGs for prints, merchandise, blog posts, whatever you need. No attribution required.
Is my data private when I use this tool?
There is no data to worry about. The fractal is generated entirely in your browser using JavaScript and the Canvas API. Nothing leaves your machine — no server calls, no analytics on your color choices, nothing. Close the tab and it is gone.