Sometimes I get the urge to create something…anything. Generating fractals from code is a good exercise in those situations and this time I decided to go with the simple Sierpinski Triangle.
Play with the two values in the demo below and hit the “Draw” button to redraw the triangle.
This movie requires Flash Player 9
Here’s a quick explanation on the logic:
For every triangle, three more triangles that are half the size of the original are generated. These are placed adjacent to each side of the original triangle. Keep repeating for every triangle created and eventually you end up with something similar to the example above.
This looks just like that thing that ground me up into little bits in Tomb Raider!!!
if you haven’t seen them already, there are some neat Sierpinski triangle examples (with source) in the Away3D examples — I especially liked the Advanced_SierpinskiTurtles.fla
http://away3d.com/