Canopy Fractal Generator
Generate and customize recursive canopy fractal trees with adjustable depth, angles, branch ratios, and colors. Export as PNG.
About
A canopy fractal is a binary branching structure where a single trunk splits recursively into two sub-branches at each node. The geometry is governed by the split angle θ, the branch length ratio r, and the recursion depth n. Small changes in θ produce dramatically different topologies: at 60° the canopy resembles a deciduous oak, while 25° produces a narrow conifer. The total number of terminal branches equals 2n, so a depth of 14 yields 16,384 endpoints. This tool computes exact trigonometric positions for every segment and renders them on a hardware-accelerated Canvas surface. An optional jitter parameter perturbs each angle by a seeded pseudo-random offset, producing organic asymmetry without losing reproducibility.
Fractal dimension of the canopy boundary depends on r and θ. When 2 ⋅ r ⋅ cos(θ) < 1, branches do not overlap and the Hausdorff dimension is ln(2)ln(1 / r). When branches overlap the structure self-intersects, creating denser fill patterns. This generator approximates but does not clip overlapping geometry. All rendering is deterministic for a given seed value.
Formulas
Each branch segment is computed recursively. Given a starting point (x0, y0), current angle α, and current length L, the endpoint is:
At each node, two recursive calls are made with updated angles:
where ε is a jitter value drawn from a seeded PRNG in the range [−J, +J]. The next branch length is:
The total number of terminal segments at depth n:
The fractal (Hausdorff) dimension when branches do not overlap:
Where: θ = split angle (degrees), r = branch length ratio (0 < r < 1), n = recursion depth, J = maximum jitter angle, ε = random perturbation per branch, L = current branch length, α = current branch angle from vertical, D = fractal dimension.
Reference Data
| Preset Name | Angle θ | Depth n | Branch Ratio r | Jitter | Terminal Branches | Visual Character |
|---|---|---|---|---|---|---|
| Symmetric Oak | 45° | 12 | 0.70 | 0° | 4,096 | Balanced deciduous crown |
| Narrow Conifer | 20° | 13 | 0.75 | 0° | 8,192 | Tall, narrow spruce |
| Wide Elm | 70° | 11 | 0.65 | 0° | 2,048 | Broad spreading canopy |
| Wind-swept | 35° | 12 | 0.68 | 8° | 4,096 | Organic, asymmetric |
| Minimal Sapling | 40° | 6 | 0.72 | 0° | 64 | Simple, few branches |
| Dense Thicket | 30° | 15 | 0.73 | 3° | 32,768 | Very dense fill |
| Right-leaning | 55° | 10 | 0.66 | 12° | 1,024 | Asymmetric, windblown |
| Fractal Dust | 90° | 14 | 0.50 | 0° | 16,384 | Cantor-set boundary |
| Golden Angle | 137.5° | 10 | 0.72 | 0° | 1,024 | Phyllotaxis-inspired spiral |
| Binary Symmetric | 60° | 10 | 0.50 | 0° | 1,024 | Self-similar, non-overlapping |
| Coral Fan | 25° | 14 | 0.80 | 5° | 16,384 | Dense, fan-shaped |
| Lightning | 15° | 14 | 0.78 | 15° | 16,384 | Jagged, electric discharge |
| Weeping Willow | 80° | 11 | 0.74 | 6° | 2,048 | Drooping, wide arcs |
| Asymmetric Bonsai | 50° | 9 | 0.60 | 10° | 512 | Irregular, sculpted look |
| Maximum Density | 35° | 16 | 0.71 | 2° | 65,536 | Near-solid canopy fill |