等高線
/**
* Copyright watanabe ( http://wonderfl.net/user/watanabe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/W0ax
*/
// forked from watanabe's 使徒襲来
// forked from hacker_n96o8lrr's forked from: BitmapDataSample9
// forked from nutsu's BitmapDataSample9
package {
import flash.text.TextFormat;
import flash.filters.BlurFilter;
import flash.text.TextField;
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.BitmapDataChannel;
import flash.geom.*;
import flash.events.Event;
[SWF(width=465,height=465,backgroundColor=0)]
public class BitmapDataSample9 extends Sprite {
private var bmpdata:BitmapData;
private var out:BitmapData
private var mapR:Array=[]
private var mapG:Array=[]
private var mapB:Array=[]
private var tf:TextField=new TextField();
public function BitmapDataSample9() {
var tfm:TextFormat = new TextFormat();
tfm.font="MS ゴシック";
tf.setTextFormat(tfm);
tf.text="ABCDEFG\nABCDEFG\nABCDEFG";
tf.scaleX=tf.scaleY=20;
// tf.filters=[new BlurFilter(4,4)];
//BitmapDataを作成して表示リストに追加
bmpdata = new BitmapData( 465, 465, false, 0 );
out = bmpdata.clone();
stage.quality="medium";
for(var i:int = 0; i < 0x100; i++) {
mapB[i] = (i%18!=0)?0:100+155*Math.random()
mapG[i] = (i%18!=0)?0:100+155*Math.random() << 8;
mapR[i] = (i%18!=0)?0:100+155*Math.random() << 16;
}
var bmp:Bitmap = new Bitmap(out,"auto",true);
addChild( bmp );
//イベント
addEventListener( Event.ENTER_FRAME, enterframe );
}
private var baseX:Number = 120;
private var baseY:Number = 120;
private var octaves:uint = 2;
private var randomSeed:int = Math.random()*0xffffffff;
private var stitch:Boolean = false;
private var fractalNoise:Boolean = true;
private var channelOptions:int = BitmapDataChannel.RED|BitmapDataChannel.BLUE;
private var grayScale:Boolean = true;
private var offset:Array = [new Point(),new Point(),new Point()];
private function enterframe(e:Event):void {
//PerlinNoise
bmpdata.perlinNoise( baseX, baseY, octaves, randomSeed,
stitch, fractalNoise, channelOptions, grayScale, offset );
var mat:Matrix=new Matrix();
mat.scale(15,15);
//bmpdata.draw(tf,mat);
offset[0].y += 3;
//offset[1].y += 1;
// offset[2].y += 0.5;
//out.applyFilter(out,out.rect,new Point(),new BlurFilter(2,2));
out.paletteMap(bmpdata,bmpdata.rect,new Point(),mapR,mapG,mapB);
}
}
}