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

Acid

@author Mr.doob
Get Adobe Flash player
by mrdoob 05 Jan 2009
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, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 0);
            damp = new ColorTransform(0, 0, 9.960937E-001, 1, 0, 0, 2, 0);
			
            addChild(new Bitmap(output));
            //addChild(new Stats());
			
            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();
        }
    }
}