BurningShipの画像のスライドショー
BurningShipで人工物に見える場所を集めました。
BurningShipはマンデルブロ集合の計算の途中で値を絶対値にするだけいいようです(192,193行)
/**
* Copyright hi.kurosawa ( http://wonderfl.net/user/hi.kurosawa )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zw0w
*/
package {
//------------------------------------------
//BurningShip(マンデルブロ集合)の画像のスライドショー
// URL:http://programmingatelier.net/
//------------------------------------------
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.utils.setTimeout;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
public class BurningShipSS extends Sprite {
//それなりの画像が出来る位置(中心)と幅(d*2)
public var arrItiData:Array = new Array(
{x:1.6739552413618408,y:-0.009813549135403249,d:0.0008116000224706308},
{x:1.5636280573810426,y:-0.0013793986899799822,d:0.00017322578898933583},
{x:1.941847403703309,y:-0.002358416853155245,d:9.573287612414848e-7},
{x:1.9417768092360967,y:-0.0023434473644053737,d:0.000015314505381262636},
{x:1.9416764117143903,y:-0.002334544167312652,d:0.0000028048544654327173},
{x:1.9415760677934528,y:-0.0018046032108859225,d:1.8440857760898865e-7},
{x:1.9415256187448733,y:-0.0015164934515342575,d:0.000010173207146124466},
{x:1.8619062997699236,y:-0.008036789915691149,d:0.0000012455547085535786},
{x:1.8605643806446575,y:-0.008712451797200245,d:0.000011535082155914693},
{x:1.8615667300762673,y:-0.004653774400091034,d:0.0002278534746847347},
{x:1.8516793677908299,y:-0.001426002077707083,d:0.00002107374852091593},
{x:1.887190321850685,y:-0.0004314235864994635,d:2.580736084620101e-7},
{x:1.8871747394426246,y:-0.00016469935434531497,d:0.000002286287513116778},
{x:1.8632409359121325,y:-0.0021872827430378,d:0.000048759294928009835},
{x:1.860477259075613,y:-0.011537852731382244,d:0.000048759294928009835},
{x:1.8617386254663364,y:-0.008631849865411101,d:0.00020814534068715348},
{x:1.861496909925913,y:-0.0028166922181311173,d:0.0001368143988123074},
{x:1.882402978198022,y:-0.00021519923066148005,d:7.960458036511746e-7},
{x:1.9074369866442336,y:-0.003531883519348859,d:0.0000015612195422437044},
{x:1.9074343717576223,y:-0.0035340181748289685,d:0.0000015612195422437044},
{x:1.9072094535920303,y:-0.0005759035650427838,d:0.000027079379067567262},
{x:1.9073796667599117,y:-0.0007512220145574307,d:0.0000038078088467103776},
{x:1.9271785880719732,y:-0.00016769463447301053,d:0.0000038078088467103776}
);
//マンデルブロ集合の描画エリア
private var bdMandelbrot:BitmapData;
public var arrColor:Array; //グラデーションカラー
public var uintHassan:uint; //発散しない時のカラー
private var intBMw:Number; //描画サイズ
private var intBMh:Number;
private var iloop:int; //描画状態(0~39)
private var iTyp:int; //画像の切り替え時のエフェクト
private var xMin:Number; //マンデルブロ集合の左上の座標値
private var yMin:Number;
private var Step:Number; //マンデルブロ集合の1ピクセルの値
private const intKurikaesi:Number = 256; //最大繰り返し数
public function BurningShipSS():void {
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
//下の2行を加えるとHTMLで定義したサイズで表示
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align =StageAlign.TOP_LEFT;
intBMw = stage.stageWidth; //描画サイズ取得
intBMh = stage.stageHeight;
//描画エリアの作成
bdMandelbrot = new BitmapData(intBMw, intBMh, false, 0xffffff);
var bm:Bitmap = new Bitmap(bdMandelbrot);
stage.addChild(bm);
bm.x = (intBMw-stage.width)/2;
bm.y = (intBMh-stage.height)/2;
fncDispSt(); //描画開始
}
//描画開始
private function fncDispSt():void {
iloop = 0; //描画位置クリア
fncSerColor(); //グラデーションカラー
uintHassan = 0x000000; //発散しない時のカラー
//それなりの画像が出来る位置テーブルの選択
var intItiData:int = getIntRand(0, arrItiData.length - 1);
var d:Number = arrItiData[intItiData].d;
//マンデルブロ集合の1ピクセルの値
if (intBMh < intBMw) {
Step = arrItiData[intItiData].d / intBMh;
} else {
Step = arrItiData[intItiData].d / intBMw;
}
Step = getNumRand(Step , Step * 1.5 );
//マンデルブロ集合上の開始位置を決める
xMin = arrItiData[intItiData].x - d + getNumRand(0, 2*d-intBMw*Step);
yMin = arrItiData[intItiData].y - d + getNumRand(0, 2 * d - intBMh * Step);
//画像の切り替え時のエフェクトを指定
iTyp = getIntRand(0, 5);
//繰り返しイベントにマンデルブロ集合の描画追加
this.addEventListener(Event.ENTER_FRAME, fncMandelbroDisp);
}
//マンデルブロ集合の描画(1/40分描画、40回繰り返し)
private function fncMandelbroDisp(e:*):void {
var bolEnd:Boolean = false
var bmItiY:int;
var bmItiX:int;
var a:Number;
var b:Number;
var xx:int;
var yy:int;
//描画時エフェクトする。
switch (iTyp) {
case 0 :
for (bmItiY = iloop; bmItiY < intBMh; bmItiY+=40) {
b = yMin + bmItiY * Step;
for (bmItiX = 0; bmItiX < intBMw; bmItiX++) {
a = xMin + bmItiX * Step;
bdMandelbrot.setPixel(bmItiX, bmItiY, fncGetColor(a, -b));
}
}
break;
case 1 :
for (bmItiY = 0; bmItiY < intBMh; bmItiY++) {
b = yMin + bmItiY * Step;
for (bmItiX = iloop; bmItiX < intBMw; bmItiX+=40) {
a = xMin + bmItiX * Step;
bdMandelbrot.setPixel(bmItiX, bmItiY, fncGetColor(a, -b));
}
}
break;
case 2 :
for (bmItiY = iloop; bmItiY < intBMh; bmItiY+=40) {
for (bmItiX = 0; bmItiX < intBMw; bmItiX++) {
yy = bmItiY + bmItiX;
yy = yy % intBMh;
b = yMin + yy * Step;
a = xMin + bmItiX * Step;
bdMandelbrot.setPixel(bmItiX, yy, fncGetColor(a, -b));
}
}
break;
case 3 :
for (bmItiY = iloop; bmItiY < intBMh; bmItiY+=40) {
for (bmItiX = 0; bmItiX < intBMw; bmItiX++) {
yy = bmItiY +intBMw- bmItiX;
yy = yy % intBMh;
b = yMin + yy * Step;
a = xMin + bmItiX * Step;
bdMandelbrot.setPixel(bmItiX, yy, fncGetColor(a, -b));
}
}
break;
case 4 :
for (bmItiY = iloop; bmItiY < intBMh; bmItiY+=40) {
for (bmItiX = 0; bmItiX < intBMw; bmItiX++) {
yy = bmItiY;
if ((bmItiX % 60) < 30) { yy += 30; }
if (yy >= intBMh) { yy -= intBMh; }
b = yMin + yy * Step;
a = xMin + bmItiX * Step;
bdMandelbrot.setPixel(bmItiX, yy, fncGetColor(a, -b));
}
}
break;
case 5 :
for (bmItiY = 0; bmItiY < intBMh; bmItiY++) {
b = yMin + bmItiY * Step;
for (bmItiX = iloop; bmItiX < intBMw; bmItiX+=40) {
xx = bmItiX;
if ((bmItiY % 60) < 30) { xx += 30; }
if (xx >= intBMw) { xx -= intBMw; }
a = xMin + xx * Step;
bdMandelbrot.setPixel(xx, bmItiY, fncGetColor(a, b));
}
}
break;
}
if (iloop >= 39) { bolEnd = true; }
iloop++;
if(bolEnd == true) {
this.removeEventListener(Event.ENTER_FRAME,fncMandelbroDisp);
var setIDName:Number = setTimeout(fncDispSt, 3000); //3秒後に実行
}
}
//マンデルブロ集合の1点でのカラー
private function fncGetColor(a:Number, b:Number):uint {
var uiCol:uint = uintHassan; //発散しないときのカラー
var x:Number=0;
var y:Number=0;
var i:int = 0;
for(i=0;i<=intKurikaesi;i++){ //最大繰り返し数繰り返し
var x2:Number=x*x;
var y2:Number=y*y;
var zx:Number=x2-y2-a;
var zy:Number=2*x*y-b;
x=Math.abs(zx);
y=Math.abs(zy);
if (x2 + y2 >= 4) {
var id:int = i % arrColor.length;
uiCol= arrColor[id];
break;
}
}
return uiCol;
}
//グラデーションカラー取得
private function fncSerColor():void {
var arrCl0:Array;
var arrCl1:Array;
var icflg:uint = 0;
while (icflg == 0) { //256階調異なるRGBがあるか?
icflg = 0;
arrCl0 = new Array();
arrCl1 = new Array();
for (var ino:int = 0; ino < 3; ino++) { //2色RGBの各値を求める
var icf:int = getIntRand(0, 2);
//var icf:int = getIntRand(1, 2);
icflg += icf;
if (icf == 1) { //明->暗
arrCl0.push(255);
arrCl1.push(0);
} else if (icf == 2) { //暗ー>明
arrCl0.push(0);
arrCl1.push(255);
} else { //適当
var icf2:int = getIntRand(0, 3);
if (icf2 == 0) {
arrCl0.push(0);
arrCl1.push(127);
} else if (icf2 == 1) {
arrCl0.push(127);
arrCl1.push(0);
} else if (icf2 == 2) {
arrCl0.push(255);
arrCl1.push(127);
} else {
arrCl0.push(127);
arrCl1.push(255);
}
//arrCl0.push(getIntRand(0, 255));
//arrCl1.push(getIntRand(0, 255));
}
}
}
arrColor = new Array();
var icoln:int = 32;// getIntRand(16, 64); //intKurikaesi;
var i:int;
var ir:uint;
var ig:uint;
var ib:uint;
for(i = 0; i < icoln; i++) { //グラデーションカラー作成
ir = arrCl0[0] + (arrCl1[0] - arrCl0[0]) * i / icoln;
ig = arrCl0[1] + (arrCl1[1] - arrCl0[1]) * i / icoln;
ib = arrCl0[2] + (arrCl1[2] - arrCl0[2]) * i / icoln;
arrColor.push(ir * 256 * 256 + ig * 256 + ib);
}
for(i = 1; i < icoln-1; i++) { //グラデーションカラー作成
ir = arrCl0[0] + (arrCl1[0] - arrCl0[0]) * (icoln-i) / icoln;
ig = arrCl0[1] + (arrCl1[1] - arrCl0[1]) * (icoln-i) / icoln;
ib = arrCl0[2] + (arrCl1[2] - arrCl0[2]) * (icoln-i) / icoln;
arrColor.push(ir * 256 * 256 + ig * 256 + ib);
}
}
//乱数
private function getIntRand(intMin:int, intMax:int):int {
return intMin + Math.floor(Math.random() * (intMax + 1 - intMin));
}
private function getNumRand(numMin:Number, numMax:Number):Number {
return numMin + Math.random() * (numMax - numMin);
}
}
}