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

forked from: fladdict challenge for amateurs

Every frame you get screen caputre of the stage.
* Generate new frame image with using last frames screen capture.
* This is a starting point of recursive generative art.
/**
 * Copyright knd ( http://wonderfl.net/user/knd )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/iDYR
 */

// forked from checkmate's fladdict challenge for amateurs
/**
 * Every frame you get screen caputre of the stage.
 * Generate new frame image with using last frames screen capture.
 * This is a starting point of recursive generative art.
 */
package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BlendMode;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.ColorTransform;
    import flash.geom.Matrix;
    import flash.geom.Point;
    
    public class Beginner extends Sprite {
        /**
         * Overwrite this update function.
         * Every frame the function is invoked with two bitmaps.
         * First one contains reference to the stage bitmap.
         * Second one contains static copy of stage.
         */
         
        public var canvas:BitmapData;
        public var drawHere:BitmapData;
        public var mat:Matrix;
         
        public function update():void{
            drawStep();
            transformStep();
            
            renderStep();
            fadeStep();
        }
        
        
        public function drawStep():void {
            //drawHere.setPixel(stage.mouseX, stage.mouseY, 0x11111111);
            drawHere.setPixel( Math.random()*480, Math.random()*480, rndHue());
        }
        public function rndHue():uint{
            var rnd : uint = 0x600 * Math.random();
            var mod : uint = rnd % 0x200;
            if(mod > 0x100) mod = 0x200 - mod;
            return rnd<0x100? 0xffff0000|(mod<<8): 
                   rnd<0x200? 0xff00ff00|(mod << 16): 
                   rnd<0x300? 0xff00ff00|mod: 
                   rnd<0x400? 0xff0000ff|(mod << 8): 
                   rnd<0x500? 0xff0000ff|(mod << 16): 
                   0xffff0000|mod ;            
        }
    
        
	public function transformStep():void
        {
			mat = new Matrix(1.005, 0.00, 0.00, 1.005, 
			Math.random()>0.9? 25-50*Math.random(): -1.2,
			Math.random()>0.9? 25-50*Math.random(): -1.2
			);
        }
        
        
        public function renderStep():void{
            canvas.draw(drawHere, mat, null,BlendMode.LIGHTEN,null,true);
        }
        
        
        public function fadeStep():void
        {
            canvas.colorTransform(drawHere.rect, 
				new ColorTransform(
					1 ,
					1 ,
					1 ,
					1,
					-1 ,
					-1 ,
					-1 ,
					0
				)
			);
        }
        
        
        /**
         * ---------------------------------------
         * DO NOT CHANGE FOLLOWING CODES
         * DO NOT ACCESS FOLLOWING PROPERTIES DIRECTLY
         * ---------------------------------------
        */
        
       
        private var bitmap:Bitmap;
        
        
        public function Beginner() {
            canvas = new BitmapData(480,480,false,0x000000);
            bitmap = new Bitmap(canvas);
            addChild(bitmap);
            addEventListener(Event.ENTER_FRAME, _update);
        }
        
        public function _update(e:Event):void{
            if(drawHere)
                drawHere.dispose();
            drawHere = canvas.clone();
            update();
        }
    }
}