Perfectly Round Circles
package {
import flash.display.Sprite;
[SWF(width=465,height=465,backgroundColor='#cccccc')]
public class PerfectlyRoundCircles extends Sprite {
public function PerfectlyRoundCircles () {
var d:int = 15;
for (var r:int = 60; r < 0.5 * 465; r += 40) {
var n:int = 2 * int (0.5 * (2 * Math.PI * r) / (1.4 * d));
for (var i:int = 0; i < n; i++) {
var s:Sprite = new Sprite;
s.graphics.lineStyle (2, 0xFFFFFF * (i % 2));
s.graphics.drawRect ( -0.5 * d, -0.5 * d, d, d);
s.x = r * Math.cos (2 * Math.PI * i / n) + 0.5 * 465;
s.y = r * Math.sin (2 * Math.PI * i / n) + 0.5 * 465;
s.rotation = 360 * i / n + 15 * (1 - 2 * (int (r / 40) % 2));
addChild (s);
}
}
}
}
}