# freeskier89→ 5. StarFractal

**URL:** <https://forum.kirupa.com/t/freeskier89-5-starfractal/177019>\
**Category:** contests\
**Created:** [January 29, 2006, 9:24am UTC](https://forum.kirupa.com/t/freeskier89-5-starfractal/177019 "2006-01-29T09:24:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![freeskier89](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@freeskier89](https://forum.kirupa.com/u/freeskier89)\
**Post date:** [January 29, 2006, 9:24am UTC](https://forum.kirupa.com/t/freeskier89-5-starfractal/177019/1 "2006-01-29T09:24:13Z")

</div>

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

```auto
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 🙂

You must see the 3 sided one :love:

-freeskier89 🙂
