# Playing with Curves Point.polar()

Actionscript:
1. [SWF(width=600, height=500, backgroundColor=0x000000, frameRate=30)]
2. var points:Array = new Array();
3. var index:int = -1;
5.     index++;
6.     if (!points[index]) points[index] = 0;
7.     return Point.polar(radius, points[index] += thetaInc);
8. }
9. ///////////////////////////////////////////////////
10. // test it out:
11.
12. var canvas:BitmapData = new BitmapData(600, 500, false, 0xFFFFFF);
13.
15.
16. var p0:Point = new Point(80, 100);
17. var p1:Point = new Point(270, 100);
18. var p2:Point = new Point(480, 40);
19. var p3:Point = new Point(170, 180);
20. var p4:Point = new Point(430, 300);
21.
23. function onLoop(evt:Event):void {
24.     for (var i:int= 0; i<100; i++){
25.
26.         // reset index;
27.         index = -1;
28.
30.         canvas.setPixel(p0.x, p0.y, 0x000000);
31.
33.         canvas.setPixel(p1.x, p1.y, 0x000000);
34.
36.         canvas.setPixel(p2.x, p2.y, 0x000000);
37.
39.         canvas.setPixel(p3.x, p3.y, 0x000000);
40.
42.         canvas.setPixel(p4.x, p4.y, 0x000000);
43.     }
44. }

The polar() function is the real trick here... the rest of the code just uses it to draw this:

The Point.polar() function is just a conversion from polar to cartesian coords:

Actionscript:
1. x = radius * Math.cos(theta);
2. y = radius * Math.sin(theta);