In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

perlinNoise play 4

Get Adobe Flash player
by Kay 06 Feb 2011
/**
 * Copyright Kay ( http://wonderfl.net/user/Kay )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/e0EW
 */

// forked from Kay's perlinNoise play 3
// forked from Kay's perlinNoise play
/*
 * perlinNoiseの色を位置情報に置き換えてみたらどうなるか試してみた
 * …だけ
 */
package {
    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 bm:Bitmap = new Bitmap(canvas);
            addChild(bm);
            addEventListener(Event.ENTER_FRAME, function (e:Event):void {
                canvas.fillRect(rect,0);
                offsets[0].offset(-2,0);
                offsets[1].offset(-4,0);
                noise.perlinNoise(64,64,2,1,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,0xffffff);
                }
            });
        }
    }
}