freeskier89→ 5. StarFractal

Wow, this has to be the fastest I have coded a fractal before. :smiley: Let me know what you think!

Stage.scaleMode = "noScale";
container=_root.createEmptyMovieClip("c1",1);
depthvar=2;
points= 2+random(6);
function CreateStar(x, y, width,r) {
 mc = _root.container.createEmptyMovieClip("s"+(depthvar++), depthvar);
 mc.lineStyle(width/4, 0x5797D7, 30);
 mc.beginFill(0x48BCE1, 50);
 for (var t = 0; t<360; t += 5) {
  (t != 0) ? mc.lineTo((width*.75+width*.25*Math.sin(t*points*Math.PI/180))*Math.cos(t*Math.PI/180), (width*.75+width*.25*Math.sin(t*points*Math.PI/180))*Math.sin(Math.PI/180*t)) : mc.moveTo((width*.75+width*.25*Math.sin(t*points*Math.PI/180))*Math.cos(t*Math.PI/180), (width*.75+width*.25*Math.sin(t*points*Math.PI/180))*Math.sin(Math.PI/180*t));
 }
 mc.endFill();
 mc._x = x;
 mc._y = y;
 mc._rotation=r;
 }
Stack = [{x:275, y:200, w:100,t:0}];
onEnterFrame = function () {
 star = Stack.shift();
 for (var t = 0; t<Math.PI*2; t += Math.PI/180*(360/points)) {
  x = star.x+star.w*(1+(1/2.5))*Math.cos(t+1.5*(Math.PI/180*(360/points)));
  y = star.y+star.w*(1+(1/2.5))*Math.sin(t+1.5*(Math.PI/180*(360/points)));
  Stack.push({x:x, y:y, w:star.w/2.5,a:t});
 }
 CreateStar(star.x, star.y, star.w,star.a*(180/Math.PI)+90);
};
onMouseDown=function(){
 container=_root.createEmptyMovieClip("c1",1);
 Stack = [{x:275, y:200, w:100,t:0}];
 points=(2+random(6));
 }

Click to generate an new fractal that is between 2 and 7 sides. 2 and 3 sided ones are the coolest :slight_smile:

You must see the 3 sided one :love:

-freeskier89 :slight_smile: