forked from: 点描で球体
綺麗なコッペパンみたいなのが出来上がります
// forked from Susisu's 点描で球体
//綺麗なコッペパンみたいなのが出来上がります
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.PixelSnapping;
import flash.events.Event;
public class dotcircle extends Sprite{
private var bmpData:BitmapData=new BitmapData(465,465,false,0xffffff);
private var stgBmp:Bitmap=new Bitmap(bmpData,PixelSnapping.AUTO,true);
private var angle:Number;
private var xpos:Number;
private var ypos:Number;
private var r:Number;
private var i:uint;
public function dotcircle(){
addChild(stgBmp);
addEventListener("enterFrame", loop);
}
private function loop(e:Event):void{
bmpData.lock();
for(i=0;i<100;i++){
// 球面上等確率
var z : Number = Math.random() * 400 - 200;
var theta : Number = Math.random() * Math.PI * 2;
var res : Number = Math.sqrt(200 * 200 - z * z);
xpos = Math.cos(theta) * res + 465 / 2;
ypos = Math.sin(theta) * res + 465 / 2;
bmpData.setPixel(xpos, ypos, 0);
}
bmpData.unlock();
}
}
}