Staaarter

Generate a Cantor Dust Fractal

Builds Cantor dust, the documented 2D product generalization of the Cantor set, by dividing a square into a 3x3 grid and keeping only the 4 corner cells at each level (dropping every edge and center cell), then recursing into each surviving corner cell, exported as SVG or PNG. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-08-05
By Staaarter Team
fractalgeneratorsvg

Overview

Introduction

The Cantor set is usually shown as points scattered along a single line, but its construction generalizes cleanly into two dimensions, and the result is Cantor dust, a genuine, documented fractal that looks exactly like its name suggests.

This tool builds it the direct way: divide a square into a 3x3 grid, keep only the 4 corner cells, and recurse into each survivor, producing a scattered field of ever-smaller squares as depth increases.

What Is Generate a Cantor Dust Fractal?

A generator for Cantor dust, the standard 2D generalization of the 1D Cantor set, formed as the Cartesian product of a Cantor set with itself along the x and y axes.

Rather than computing that product directly, this tool uses the equivalent and more intuitive grid rule: divide each surviving square into a 3x3 grid of sub-squares and keep only the 4 corners, discarding the center and all 4 edge-midpoint cells.

How Generate a Cantor Dust Fractal Works

Starting from one full square, each level divides every surviving square into a 3x3 grid of equal sub-cells, then keeps only the cells where both the row and column are at an edge, not the middle, which is exactly the 4 corners.

Every surviving corner cell becomes a new square one-third the size of its parent, and the same keep-4-corners rule is applied inside it again at the next level, recursively.

Because 4 of 9 cells survive each level, the count of squares multiplies by 4 every iteration (4^depth squares at the final depth) while each square's side length shrinks by a factor of 3, producing the characteristic sparse, scattered pattern.

When To Use Generate a Cantor Dust Fractal

Use it to see a concrete, visual example of how a 1D fractal construction (the Cantor set) generalizes into 2D, useful for teaching product constructions in fractal geometry.

It's also a clean illustration of self-similarity in two dimensions: zoom into any surviving corner square and you'll find the exact same 4-corners pattern repeated.

Features

Advantages

  • Directly illustrates the Cartesian-product relationship between the 1D Cantor set and its 2D generalization using a simple, visual grid rule.
  • Produces a clearly self-similar pattern at every surviving corner, useful for demonstrating fractal self-similarity in two dimensions.
  • Exports as clean vector SVG or a flattened PNG for use in teaching materials or illustrations.

Limitations

  • Depth is capped at 6, since the square count grows as 4^depth and already reaches over 4,000 squares by depth 6.
  • The tool renders filled squares at every surviving cell rather than an infinitely fine dust of zero-area points, which is the true mathematical limit; the rendered result is a finite-depth approximation.

Examples

Depth 0

Input

Depth = 0

Output

A single filled square, the untouched starting shape.

At depth 0, no subdivision has happened yet.

Depth 3

Input

Depth = 3

Output

64 small squares (4^3) scattered in a self-similar corner-clustering pattern across the drawing area.

Each level multiplies the square count by 4 (keeping only the 4 corners of each 3x3 subdivision), so depth 3 yields 4x4x4 = 64 squares.

Best Practices & Notes

Best Practices

  • Start around depth 3 or 4 to see the clustering pattern clearly before the squares become too small to distinguish at higher depths.
  • Compare it against the 1D Cantor Set Generator to see how the same middle-removal idea looks when extended to a second axis.

Developer Notes

Implemented via the shared `subdivideGrid` recursive helper with `gridSize = 3` and a `keep(row, col)` predicate of `row !== 1 && col !== 1`, which is true only for the 4 corner cells of the 3x3 grid. This differs from the Sierpinski carpet's predicate (`!(row === 1 && col === 1)`, which keeps 8 of 9 cells) only in which cells are excluded, illustrating how small changes to the same grid-subdivision helper produce entirely different fractal families.

Generate a Cantor Dust Fractal Use Cases

  • Teaching the Cartesian-product relationship between 1D and 2D fractal constructions
  • Producing a reference image of Cantor dust for a fractal geometry course or article
  • Comparing keep-4-corners density against the Sierpinski carpet's keep-8-of-9 density using the same grid-subdivision idea

Common Mistakes

  • Confusing this with the Sierpinski carpet, that pattern keeps 8 of 9 cells (dropping only the center) and looks like a connected mesh; Cantor dust keeps only 4 corner cells and looks like scattered, disconnected squares.
  • Expecting the squares to shrink to true zero-area points, this tool renders a finite-depth approximation with visibly sized squares, not the infinite mathematical limit.

Tips

  • Try the Z-order Curve Generator to see a different way of organizing a 2D grid, visiting cells in a specific traversal order rather than recursively excluding them.
  • Download as SVG to inspect how the corner-clustering pattern repeats at finer scales when zoomed in.

References

Frequently Asked Questions