Draw Cantor Dust Fractal Online
Generate the 2D Cantor dust fractal with custom iterations, size, and colors
Generate Cantor dust fractals — the 2D version of the Cantor set — by picking an iteration depth, canvas size, and color scheme, then clicking Draw. The pattern renders on an HTML Canvas and exports as a PNG in one click. And everything runs in your browser. Nothing gets uploaded.
How It Works
The algorithm takes one filled square and divides it into a 3×3 grid of nine sub-squares. It throws away the center square and the four edge squares, leaving only the four corners. Then it does the exact same thing to each of those four corners — over and over, as many times as you tell it. At iteration 5, that’s 1,024 tiny squares. At iteration 8, it is 65,536.
Examples
Math class poster at iteration 4
A teacher needs a clean fractal image for a lesson on self-similarity and fractal dimension.
Iterations: 4
Canvas: 729px
Background: #ffffff
Dust: #1e3a5f
Border: #1e3a5f
256 dark blue squares on white
729×729 PNG download
Clean, print-ready image
Desktop wallpaper — neon on black
You want a dark-themed fractal wallpaper with bright accents. Crank the iterations up and use a large canvas.
Iterations: 6
Canvas: 1458px
Background: #0f1117
Dust: #00ff88
Border: #00cc66
4,096 neon green squares
1458×1458 high-res PNG
Looks great on a dark desktop
Quick iteration comparison for a blog post
A writer is illustrating how fractal detail increases with each iteration level. They generate three images side by side.
Run 1: Iterations 2 → 16 squares
Run 2: Iterations 4 → 256 squares
Run 3: Iterations 6 → 4,096 squares
Same colors, same 729px canvas
Three PNGs showing the fractal
growing from chunky blocks to
fine dust — perfect side-by-side
comparison for the article
Who Uses This
Generate fractal visuals for lessons on recursion, self-similarity, and fractal dimension.
Grab a quick PNG for placeholder graphics, loading screens, or generative art projects.
Create geometric patterns and textures for posters, album covers, or social media graphics.
Illustrate homework or presentations on fractals without writing code from scratch.
Common Mistakes
At iteration 7 on a 200px canvas, each dust square is smaller than a single pixel. The result looks like random noise. Use a canvas size of at least 729px for iterations above 5, or bump it to 1458px or 2000px for iterations 7-8.
If your dust color is #333 on a #222 background, the pattern barely shows up. Pick colors with strong contrast — dark background with a bright dust color works best for visibility.
Cantor dust subdivides into a 3×3 grid each time, so canvas sizes like 243, 729, or 2187 give pixel-perfect alignment. Other sizes still work but you might notice slight blurriness at higher iterations where squares don’t land on exact pixel boundaries.
Technical Details
- Processing: 100% client-side — Canvas API rendering
- Browser Support: Chrome, Firefox, Safari, Edge
- Max Canvas: 2000×2000 pixels
- Iterations: 1 to 8 (4^n squares at depth n)
- Export: PNG download at full canvas resolution
Frequently Asked Questions
What is Cantor dust exactly?
Cantor dust is the two-dimensional version of the Cantor set. You take a filled square, chop it into a 3×3 grid, and toss out everything except the four corner squares. Then you do the same thing to each corner, forever. The resulting shape has a fractal dimension of about 1.26 — it’s more than a line but less than a surface.
Why does the default canvas size use 729 pixels?
729 equals 3 to the sixth power. Since the fractal splits each square into a 3×3 grid, powers of 3 let every sub-square land perfectly on pixel boundaries. That means crisp edges with no anti-aliasing fuzz. Other sizes work fine, but 243, 729, and 2187 give the sharpest results.
How is Cantor dust different from the regular Cantor set?
The classic Cantor set works in one dimension — you remove the middle third of a line segment, then keep removing middle thirds from what’s left. Cantor dust does the same thing but in two dimensions, working with squares instead of lines. Think of it as applying the Cantor set rule along both the x-axis and y-axis at the same time.
Can I use the generated image commercially?
Yes. The image is generated entirely in your browser using a mathematical algorithm. There’s no copyright on the Cantor dust pattern itself — it is a mathematical object. The PNG you download is yours to use however you want.
What iteration level gives the best-looking result?
For a 729px canvas, iterations 4 to 5 hit the sweet spot — enough detail to clearly see the fractal self-similarity without the squares becoming invisibly small. Going to 6 or 7 still looks good on larger canvases (1458px+), but beyond that the dust particles are sub-pixel on most screens.