Recursion you can look at. One branch becomes two, each of those becomes two more, and it stops when a branch is too short to be worth drawing. The slider sets the angle the branches split at.
↑ drag this slider to change the angle the branches split at
| Platform | Engine | Project |
|---|---|---|
| Web browser | Javascript, p5.js | Individual project |
A fractal tree is recursion you can see. The sketch draws one trunk line, then rotates by an angle, draws a branch at 0.67 of the length, rotates the other way and draws its mirror, and repeats that until the branch length falls below 4 pixels and the recursion stops.
That single angle is the whole silhouette. At 0.1 radians the branches stay nearly vertical and it reads as a poplar; at PI/2 they spread horizontally and it becomes a fern. Everything else about the tree - how many branches there are, how thick it looks, how it fills the canvas - comes out of that one number.
Want to work together?
marc.kletz@kletzgames.com