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: forked from: Acid

@author Mr.doob
Get Adobe Flash player
by Libr8d 14 Jun 2009
    Embed
// forked from plankton's forked from: Acid
// forked from mrdoob's Acid
package  
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BlendMode;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.ConvolutionFilter;
    import flash.geom.ColorTransform;
    import flash.geom.Matrix;
    import flash.geom.Point;

    import net.hires.debug.Stats;		

    /**
     * @author Mr.doob
     */
    [SWF(backgroundColor="#000000")]

    public class ColourTest extends Sprite 
    {
        public var w : int;
        public var h : int;
        public var t : int = 0;
        public var output : BitmapData;
        public var buffer : BitmapData;
        public var point : Point;
        public var matrix : Matrix;
        public var blurFilter : ConvolutionFilter;
        public var damp : ColorTransform;

        public function ColourTest()
        {
            addEventListener( Event.ADDED_TO_STAGE, init );
        }

        private function init( e : Event ) : void
        {
            removeEventListener( Event.ADDED_TO_STAGE, init );

            w = stage.stageWidth;
            h = stage.stageHeight;


            output = new BitmapData(w, h, false, 0x000000);
            buffer = new BitmapData(w, h, false, 0x000000);
			
            point = new Point();
            matrix = new Matrix();
            matrix.a = matrix.d = 2;
            blurFilter = new ConvolutionFilter(3, 2, [0.1, .5, 2, 1, 1, 1, 1, 1, 1], 8, 0);
            damp = new ColorTransform(0, 0, 6.950937E-001, 1,3, 2, 1, 2);
			
            addChild(new Bitmap(output));
			
            addEventListener(Event.ENTER_FRAME, loop);
        }

        public function loop(e : Event) : void
        {
            var random_x : int = Math.random() * w;
            var random_y : int = Math.random() * h;
			
            output.setPixel(random_x, random_y, Math.random() * 0xffffff);
			
            output.applyFilter(output, output.rect, point, blurFilter);
            output.draw(output, null, null, BlendMode.ADD);
            output.draw(buffer, matrix, null, BlendMode.SUBTRACT);
            buffer = output.clone();
        }
    }
}