PerlinNoise
/**
* Copyright yun ( http://wonderfl.net/user/yun )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wxda
*/
// forked from yun's DisplacementMapFilterのエフェクト
// forked from yun's BlurFilterのエフェクト
// forked from yun's BlendModeの指定
// forked from yun's ColorTransformの指定
// forked from yun's Matrixの指定
// forked from yun's BitmapDataへの描画
package {
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.BitmapDataChannel;
import flash.geom.Point;
import flash.events.Event;
import flash.filters.DisplacementMapFilter;
[SWF(width = 465, height = 465, backgroundColor = 0, frameRate = 30)]
public class BitmapDataSample extends Sprite {
private var bmpdata:BitmapData;
private var filter:DisplacementMapFilter;
public function BitmapDataSample() {
// BitmapDataを作成して表示リストに追加
bmpdata = new BitmapData(120, 120, false, 0);
var bmp:Bitmap = new Bitmap(bmpdata);
bmp.scaleX = bmp.scaleY = 4;
addChild(bmp);
// イベント
addEventListener(Event.ENTER_FRAME, enterframe);
}
private var baseX:Number = 100;
private var baseY:Number = 100;
private var octaves:uint = 10;
private var randomSeed:int = Math.random() * 0xffffffff;
private var stitch:Boolean = false;
private var fractalNoise:Boolean = true;
private var channelOptions:int = BitmapDataChannel.RED | BitmapDataChannel.GREEN | BitmapDataChannel.BLUE;
private var glayScale:Boolean = false;
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, glayScale, offset)
offset[0].y += 2;
offset[1].y += 1;
offset[2].y += 0.5;
}
}
}