Point.polar() Stars

Actionscript:
  1. [SWF(width=700, height=400, backgroundColor=0x000000, frameRate=30)]
  2.  
  3. var points:Array = new Array();
  4. var index:int = -1;
  5. function polar(thetaInc:Number, radius:Number):Point{
  6.     index++;
  7.     if (!points[index]) points[index] = 0;
  8.     return Point.polar(radius, points[index] += thetaInc)
  9. }
  10. ///////////////////////////////////////////////////
  11. // test it out:
  12.  
  13. var canvas:BitmapData = new BitmapData(700, 400, false, 0xFFFFFF);
  14.  
  15. addChild(new Bitmap(canvas, "auto", true));
  16.  
  17. var p0:Point = new Point(200, 200);
  18. var p1:Point = new Point(500, 200);
  19.  
  20. addEventListener(Event.ENTER_FRAME, onLoop);
  21. function onLoop(evt:Event):void {
  22.    
  23.     var rad:Point = polar(.05, 4);
  24.      
  25.     for (var i:int= 0; i<100; i++){
  26.        
  27.         // reset index;
  28.         index = -1;
  29.        
  30.         p0 = p0.add(polar(.025, 2).add(polar(-.05,rad.x)));
  31.         canvas.setPixel(p0.x, p0.y, 0x000000);
  32.        
  33.         p1 = p1.add(polar(.025, 2).add(polar(-.05,rad.x).add(polar(.1, rad.y))));
  34.         canvas.setPixel(p1.x, p1.y, 0x000000);
  35.     }
  36. }

This is pretty much the same as yesterdays... I just changed the way I use the polar() function to draw two more shapes:

This entry was posted in BitmapData, motion, setPixel 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 *

*
*