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

Natural Algorithms are Beautiful

I dont get how this is performing as well as it does.... happy accident?

[ff]: whatever
Get Adobe Flash player
by bradsedito 02 Aug 2012
/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/vaKa
 */

/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/vaKa
 */
package 
{
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.geom.*;    
    import mx.utils.Base64Decoder;
    import net.hires.debug.Stats;
 
 
    public class FlashTest extends Sprite 
    {        
        private const seed:uint = Math.random() * 0x40000000;//000000;  // 0x80000000;
        private var p1:Point = new Point(0, 0);
        private var p2:Point = new Point(32, 32);
        private var bd:BitmapData;
        private var stats:Stats = new Stats();        

        public function FlashTest() 
        {
            stage.scaleMode = StageScaleMode.EXACT_FIT;
            stage.align = StageAlign.TOP;
            stage.frameRate = 90;
            stage.addChild( stats );
            // ENTRY POINT:
            
            var d:Base64Decoder = new Base64Decoder();
            d.decode('oQECAAAMX091dENvb3JkAKMABHNyYwChAgQBAA9kc3QAMAEA8QAAEAAdAgDBAQAAAAkCAIABAEAACQIAgAEAgAAKAgBAAQBAAAoCAEABAIAAAgIAQAIAAAACAQDiAgAAAAUBAOICAFQA');
            var sf:ShaderFilter = new ShaderFilter(new Shader(d.toByteArray()));
            bd = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x000000);
            addChild(new Bitmap(bd)).filters = [sf];
            addEventListener(Event.ENTER_FRAME, frame);
        }
        
        
        private function frame(e:Event):void 
        {
            bd.perlinNoise(
                79, 128, 3,   //   128, 128, 2,
                seed,
                true, true,
                BitmapDataChannel.RED | BitmapDataChannel.BLUE,// | BitmapDataChannel.ALPHA,    //  | BitmapDataChannel.GREEN
                false,
                [p1, p2]
            );
            var p2SqrtX:Number = Math.sqrt( p1.x );
            var p2SqrtY:Number = Math.sqrt( p1.y );
            p1.x  +=  Math.SQRT1_2;
            p1.y  +=  1;
            //p2.x   =  p2SqrtX;
            //p2.y   =  p2SqrtY;
            p2.x += Math.SQRT2;
            p2.y += 1;
        }       
    }
}



/*
parameter "_OutCoord", float2, f0.rg, in
texture "src", t0
parameter "dst", float4, f1, out

; f1 = sample()
texn f1, f0.rg, t0
; f2.r = min(f1.r, f1.g, f1.b)
; f2.g = max(f1.r, f1.g, f1.b)
mov f2.rg, f1.rr
min f2.r, f1.g
min f2.r, f1.b
max f2.g, f1.g
max f2.g, f1.b
; f1.rgb = (f1.rgb - f2.rrr) / (f2.ggg - f2.rrr)
sub f2.g, f2.r
sub f1.rgb, f2.rrr
div f1.rgb, f2.ggg
*/