Tools

Home
Password GeneratorLorem IpsumCoin FlipperRandom StringToken GeneratorRandom Color

Triangle Dragon Fractal

Draw terdragon / triangle dragon fractals with custom iterations, colors, and line width

Your files never leave your browser
Ready·Canvas rendering

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

Set Iterations & Colors
➔
Build Turn Sequence
➔
Render on Canvas

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

INPUT
Iterations: 3 Line color: #6366f1 Background: #ffffff Line width: 2
OUTPUT
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

INPUT
Iterations: 10 Line color: #22d3ee Background: #0f172a Line width: 1
OUTPUT
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

INPUT
Render at iterations 4, 6, 8, 10 Same colors for each Download each as PNG
OUTPUT
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

👨‍🏫 Math Teachers

Show students how a simple substitution rule generates infinite complexity — no coding needed.

🎨 Generative Artists

Export fractal PNGs as texture layers or poster backgrounds with custom color schemes.

📐 CS Students

Visualize L-system concepts and recursive geometry before writing their own implementations.

📝 Math Bloggers

Grab clean fractal images for articles about space-filling curves and tiling theory.

Common Mistakes

Jumping straight to iteration 12

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.

Using a thick line width at high iterations

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.

Picking low-contrast color combos

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

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.

Share: