Messy Code

Actionscript:
  1. var xp:Number=0,yp:Number=0;
  2. var r:Number=0,t:Number=0;
  3. var speed:Number=.01;
  4. var scale:Number=10;
  5. var shape:Shape = Shape(addChild(new Shape()));
  6. shape.x=stage.stageWidth/2;
  7. shape.y=stage.stageHeight/2;
  8. shape.graphics.lineStyle(0,0x000000);
  9.  
  10. var s:Number=100;
  11. var range:Number=.2;
  12. var b:Number=20;
  13. var a:Number =b*range;
  14.  
  15. addEventListener(Event.ENTER_FRAME, onLoop);
  16. function onLoop(evt:Event):void {
  17.     range=.2;
  18.     b=20;
  19.     a=b*range;
  20.     t=0;
  21.     shape.graphics.clear();
  22.     shape.graphics.lineStyle(0,0);
  23.     for (var i:int = 0; i<6000; i++) {
  24.         var sin:Number=Math.cos(t*int(mouseY/20));
  25.         r =  Math.sqrt(40 * b * (b - a * (Math.pow(sin, int(mouseX/20)))));
  26.         xp=r*Math.cos(t);
  27.         yp=r*Math.sin(t);
  28.  
  29.         if (t==0) {
  30.             shape.graphics.lineStyle(0, 0);
  31.             shape.graphics.moveTo(xp, yp);
  32.         } else {
  33.             shape.graphics.lineTo(xp, yp);
  34.         }
  35.         t+=speed;
  36.         if (t> (2 * Math.PI + speed)) {
  37.             range+=.3;
  38.             a=b*range;
  39.             t=0;
  40.         }
  41.     }
  42. }

This is an example of raw messy code that draws some interesting shapes. I was waiting somewhere with my laptop a few weeks back and I wrote this and e-mailed this to myself - it's completely unoptimized and unedited.

I was working on documentation for QuickBox2D today but didn't finish it - so I posted this instead. I hope to finish the docs for tomorrow...

This entry was posted in misc and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*