shaderClasses.LuminosityShader

by bradsedito forked from Creative Suite blend modes (diff: 12)
♥0 | Line 51 | Modified 2011-03-14 03:19:06 | MIT License
play

ActionScript3 source code

/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pW8N
 */

// forked from wh0's Creative Suite blend modes
package {
    import mx.graphics.shaderClasses.*;
    import mx.graphics.shaderClasses.LuminosityShader;
    import flash.utils.getTimer;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.geom.Matrix;
    import flash.display.*;
    public class FlashTest extends Sprite {
        
        private static const s:Number = 10. / 0x4000;
        private static const t:Number = 360. / 20000;
        
        private var dim:Number = 700;
        private var loader:Loader;
        private var icon:Loader;
        private var grad:Shape;
        
        public function FlashTest() {
            loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
            loader.load(new URLRequest(loaderInfo.parameters['viewer.iconURL']));
            grad = new Shape();
            grad.graphics.beginGradientFill(
                GradientType.RADIAL,
                [0xffc000, 0xff0060],
                [1, 1],
                [0, 255],
                new Matrix(s * dim, 0, 0, 1, 0, 0)
            );
            grad.graphics.drawRect(-dim / 2, -dim / 2, dim, dim);
            grad.x = stage.stageWidth / 2;
            grad.y = stage.stageHeight / 2;
          grad.alpha = .5;
            grad.blendShader = new ExclusionShader();
            addEventListener(Event.ENTER_FRAME, frame); 
        }
        
        private function complete(e:Event):void {
            icon = new Loader();
            icon.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
                icon.width  = icon.width   * 2.0;
                icon.height = icon.height  * 2.0;
                icon.x = (stage.stageWidth  / 2.0);
                icon.y = (stage.stageHeight / 2.0) - 100
 //             icon.scaleX = .5;    icon.scaleY = .5;
            });
            icon.loadBytes(loader.contentLoaderInfo.bytes);
            addChild(icon); 
            addChild(grad);            
        }            
       
         
        private function frame(e:Event):void {
            grad.rotation = getTimer() * t;
        }
        
    }
}