Last week I sat down to see how I can generate a fractal tree on a web page. It turned out to be a very interesting exercise using HTML5 Canvas and simple Math trigonometric functions. Using random numbers for changing the length of the tree branch, and the angle of branch split -- I was quite successful in generating very realistic looking trees!
Each time you render the HTML, the trees look quite different. I can see how Game creators can create interesting looking forests for "heroes" to travel in using such techniques.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTQ0hd2cnhoPHFXVoS3fJzdeZG6RQZxPJgE1zoxF5K63dvLR8hWCRzbun3Qd4A2wRV9EpiBMQpCEqJY-mRJ66gfutL_QnukHnApGvESMDHLP5ELuV1siAI0dKtxZ4MjHDVG0Jibl30yTs/s400/Screen+Shot+2012-08-12+at+1.37.54+PM.png) |
HTML 5 Canvas with a Fractal Tree
|
Here is the code (also posted on github):
No comments:
Post a Comment