forked from: perlinNoise play 4
perlinNoiseの色を位置情報に置き換えてみたらどうなるか試してみた
…だけ
/**
* Copyright 0xABCDEF ( http://wonderfl.net/user/0xABCDEF )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bRJp
*/
// forked from Kay's perlinNoise play 4
// forked from Kay's perlinNoise play 3
// forked from Kay's perlinNoise play
/*
* perlinNoiseの色を位置情報に置き換えてみたらどうなるか試してみた
* …だけ
*/
package {
import flash.geom.ColorTransform;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.events.Event;
public class FlashTest extends Sprite {
private var offsets:Array = [new Point(), new Point()];
private var rect:Rectangle = new Rectangle(0,0,460,460);
public function FlashTest() {
var noise:BitmapData = new BitmapData(128,128);
var canvas:BitmapData = new BitmapData(460,460,false,0xff000000);
var seed:int = Math.random();
var bm:Bitmap = new Bitmap(canvas);
addChild(bm);
addEventListener(Event.ENTER_FRAME, function (e:Event):void {
canvas.fillRect(rect,0);
offsets[0].offset((stage.stageWidth/2-mouseX)/20,(stage.stageWidth/2-mouseY)/20);
offsets[1].offset((stage.stageWidth/2-mouseX)/10,(stage.stageWidth/2-mouseY)/10);
noise.perlinNoise(64,64,10,seed,true,true,7,false,offsets);
for (var i:int = 0; i < 16384; i++) {
var nX:Number = i/128;
var nY:Number = i%128;
var rgb:int = noise.getPixel( nX, nY );
var nR:int = (rgb >> 16) & 0xff;
var nG:int = (rgb >> 8) & 0xff;
var nB:int = rgb & 0xff;
canvas.setPixel( nG/4+nX*2+83, nB/4+nY*2+83, rgb );
}
});
}
}
}