View Full Version : Fractals!

09-01-2004, 07:16 AM
Yes, it's those shapes we all know and love. Well, maybe not all, and perhaps not love. But anyway, how cool are they? They repeat, and you can just keep going and going... I was inspired by these to make my own fractal generator... and i decided to try to keep to these rule things so i could send it in here :P. With my dad's help, i managed to make one which is of repeating triangles, and it is as follows (you can even print it, though it's about 2.21 MB :P)

_root.createEmptyMovieClip("Pen", 1)
_root.triangle = function(Long, x, y) {
_root.pen.lineTo(x + Long, y + Math.sqrt(3) * Long)
_root.pen.lineTo(x - Long, y + Math.sqrt(3) * Long)
lengthvar = 256; ax=4; ay=4
_root.triangle(-lengthvar,lengthvar + ax, Math.sqrt(3) * lengthvar + ay)
_root.fractal = function(lengthvarq, axq, ayq, max) {
for (i = 0; i <max+1; i ++) {
axq+= lengthvarq
_root.triangle(lengthvarq, axq, ayq)
_root.fractal(lengthvarq, axq - 2 * lengthvarq, ayq, max)
_root.fractal(lengthvarq, axq, ayq, max)
_root.fractal(lengthvarq, axq - lengthvarq, ayq + Math.sqrt(3)*lengthvarq, max)
_root.fractal(lengthvar, ax, ay, 8)
_root.pen.onRelease = function() {print(_root, "bframe")}

However, this is a pretty inefficient way of doing things (as you may notice if you run it). How's about we see what else we can make?