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 3

Get Adobe Flash player
by Kay 05 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/jpfJ
 */

// 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(1,1);
                offsets[1].offset(-1,-1);
                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(nX+166,nB+nY*2,rgb);
                }
            });
        }
    }
}