Flash Bestiary / Natural Phenomena / Fern Fractal |
|
Fern FractalThis program draws a fern or tree using a recursive function (a function which calls itself). Recursion is commonly used to create fractals, as it results in self-similarity. Increasing the level of recursion will make the tree look better, but will also make it take longer to draw. At level 10 it can take a looooooong time to draw. Be patient. The method I'm using is closely related to (and produces similar results to) an L-System or Lindenmeyer system. It's faster than an L-System, but not as general purpose, because the basic structure of the tree is hard-coded into the drawing algorithm. The source code is surprisingly short. Here's the part which draws the tree:
function drawFern(px,py,a,rad,level) |
|
|
|
Next: Deep Blue Sea |
Copyright © 2003,2008 by Jim Bumgardner. All Rights Reserved. Leave Jim some feedback