This is a Javascript port of a Flash project I wrote in 2011[1], which no longer ran in a browser after 2020. I tweaked it a bit after porting the code. And then a few years later, Ruffle.rs let the Flash project run again.
Size:
The basic idea is to create the tree structure through recursion. Start with a trunk and then spawn several branches. At the end of each branch spawn several more branches. Then draw a leaf cluster at the end of each of these branches, including the intermediate ones. A leaf cluster is just a few green circles.
If you want to dig deep into recursion for tree and plant generation, see the book Algorithmic Beauty of Plants[3] [PDF].