Recursively Drawing Trees with JavaScript and Canvas

I have written an article titled Graphics Programming with Canvas for the upcoming December 2009 edition of JSMag. One of the examples I came up with for the article was a recursive tree drawing algorithm. I had quite a bit of fun tweaking different values and seeing what sort of tree would be produced. After a while it got a bit boring changing a value, saving the JavaScript and then refreshing the page, so with the help of jQuery UI I came up with an interactive version. Below are a couple of tree images I've generated with the tool:



You can view the page source to see what's going on behind the scenes, but for full details check out the December edition of JSMag. Give it a try for yourself, generate your own tree!

Posted on 22 Nov 2009
If you enjoyed reading this post you might want to follow @coderholic on twitter or browse though the full blog archive.