Thursday, July 19, 2012

JavaScript Tree Fractal

Hello Everyone! Today we are going to discuss one of the most simple and beautiful fractals there is, the Tree Fractal!
Algorithm (very simple one):
1. Draw a line
2. From the end of that line draw another two lines, that are split by an angle
3. Repeat with shorter lines, but with the same angle
 Now, I've taken a code from http://rosettacode.org/wiki/Fractal_tree , and made some changes in it so you can have the opportunity to create your own tree fractal right here in the site,
So Here Is The JavaScript Code:


Just enter the parameters(angle and depth) and it will create you the tree(credit for rosettacode):
BEWARE - to much depth will get your browser stuck!
Angle: Depth:            
 

1 comment:

  1. Pretty cool! Check out http://slicker.me/fractals/animate.htm to see animated Julia fractal in 32 lines of pure JS

    ReplyDelete