//各変数の宣言とかは適宜;
//SIZEの値は500 (500×500pxの範囲で描画)
private function drawGumowskyMira(e:Event):void {
// ------------------ Gumowsky-Mira Mapping-------------------
bmp.lock();
for (var j:int = 0; j <= 80; j++) {
_x = 40.0 * (Math.random() - 0.5); //初期値を乱数で与える
_y = 40.0 * (Math.random() - 0.5);
k = Math.floor(256 * (_x * _x + _y * _y)); //色決め
fx=a*x+aa*x*x/(1+x*x);
//写像の繰り返し
for (var i:int = 0; i < 1000; i++) {
x1 = _y+fx;
xx1 = x1*x1;
fx = a*x1+aa*xx1/(1+xx1);
_y = -_x+fx;
_x = x1;
if (Math.abs(_x) < 40.0 && Math.abs(_y) < 40.0) {
pt.x = Math.floor(SIZE / 80 * _x); //ptはPoint型
pt.y = Math.floor(SIZE / 80 * _y);
bmp.setPixel(pt.x + SIZE/2, pt.y + SIZE/2, changeColor(k));
}
}
}
bmp.unlock();
}
private function changeColor(n:int):uint {
var r:uint = (n & 0x2f) << 2;
var g:uint = (n & 0x1f) << 3
var b:uint = (n & 0xf) << 4;
return r << 16 | g << 8 | b;
}