Cantor Dust Fractal Generator
Generate and visualize Cantor Dust fractals with adjustable iterations, colors, and gap ratios. Export high-resolution PNG images of this 2D Cantor Set.
About
Cantor Dust is the two-dimensional analog of the classical Cantor Set, constructed by taking the Cartesian product of two middle-thirds Cantor Sets. At each iteration, a filled square is subdivided into a 3 ร 3 grid and only the four corner sub-squares are retained. After n iterations the figure contains 4n squares, each with side length (1 รท 3)n of the original. The Hausdorff dimension converges to log(4) รท log(3) ≈ 1.2619, making it a measure-zero set with non-integer dimension. Miscounting iterations or misunderstanding the gap ratio leads to incorrect fractal dimension estimates in academic work. This tool applies the exact recursive subdivision and lets you vary the gap fraction from the classical 1/3 removal to arbitrary proportions, useful for studying generalized Cantor constructions.
The generator renders up to 8 levels of recursion in real time on an HTML5 Canvas. Note: at iteration 8 the renderer draws 65,536 rectangles. Higher iterations are supported but rendering time increases by a factor of 4 per level. The gap ratio parameter controls what fraction of each sub-square is removed. A ratio of 0 produces a filled square. A ratio approaching 1 collapses the dust to four points. Classical Cantor Dust uses a gap ratio of 1/3.
Formulas
The classical Cantor Dust is formed by recursively removing the center cross from a square. At each recursion level, each surviving square of side s is divided into a 3 ร 3 grid and only the 4 corner cells are kept.
The total filled area after n iterations is:
The Hausdorff (fractal) dimension is:
For a generalized gap ratio g (where 0 < g < 1), the scaling factor becomes r = (1 โ g) รท 2, and the fractal dimension generalizes to:
Where N(n) = number of squares at iteration n. s(n) = side length of each square at iteration n. A(n) = total filled area fraction. D = Hausdorff dimension. r = contraction ratio. g = gap ratio (fraction removed from the center). N = number of self-similar pieces (4 for Cantor Dust).
Reference Data
| Iteration (n) | Squares | Side Length | Total Filled Area | Removed Area | Cumulative Ratio |
|---|---|---|---|---|---|
| 0 | 1 | 1 | 1.0000 | 0.0000 | 100.00% |
| 1 | 4 | 1/3 | 0.4444 | 0.5556 | 44.44% |
| 2 | 16 | 1/9 | 0.1975 | 0.8025 | 19.75% |
| 3 | 64 | 1/27 | 0.0878 | 0.9122 | 8.78% |
| 4 | 256 | 1/81 | 0.0390 | 0.9610 | 3.90% |
| 5 | 1,024 | 1/243 | 0.0173 | 0.9827 | 1.73% |
| 6 | 4,096 | 1/729 | 0.0077 | 0.9923 | 0.77% |
| 7 | 16,384 | 1/2187 | 0.0034 | 0.9966 | 0.34% |
| 8 | 65,536 | 1/6561 | 0.0015 | 0.9985 | 0.15% |
| 9 | 262,144 | 1/19683 | 0.00068 | 0.99932 | 0.068% |
| 10 | 1,048,576 | 1/59049 | 0.00030 | 0.99970 | 0.030% |
| n | 4n | (1/3)n | (4/9)n | 1 โ (4/9)n | - |