topical media & game development

talk show tell print

#graphic-flex-image-effects-07-source-aether-effects-shaders-LiteBriteEffect.ax

#graphic-flex-image-effects-07-source-aether-effects-shaders-LiteBriteEffect.ax [swf] [flash] flex


  package aether.effects.shaders {
  
          import aether.utils.MathUtil;
  
          public class @ax-graphic-flex-image-effects-07-source-aether-effects-shaders-LiteBriteEffect extends ShaderEffect {
  
                  public static var shaderClass:String = "LiteBriteKernel";
                  public static var shaderFile:String = "liteBrite.pbj";
  
                  private var _backgroundColor:uint;
                  private var _threshold:Number;
  
                  public function @ax-graphic-flex-image-effects-07-source-aether-effects-shaders-LiteBriteEffect(
                          threshold:Number=.4,
                          backgroundColor:uint=0xFF000000,
                          blendMode:String=null,
                          alpha:Number=1
                  ) {
                          _shaderClass = shaderClass;
                          _shaderFile = shaderFile;
                          this.threshold = threshold;
                          this.backgroundColor  = backgroundColor;
                          init(blendMode, alpha);
                  }
                  
                  override protected function configureShader(data:Object):void {
                          data.levelsThreshold.value =  [threshold];
                          data.backgroundColor.value = [
                                  (_backgroundColor >> 16 & 0xFF)/0xFF,
                                  (_backgroundColor >> 8 & 0xFF)/0xFF,
                                  (_backgroundColor & 0xFF)/0xFF,
                                  (_backgroundColor >> 24 & 0xFF)/0xFF
                          ];
                  }
                  
                  public function set backgroundColor(color:uint):void {
                          _backgroundColor = color;
                  }
  
                  public function set threshold(threshold:Number):void {
                          _threshold = MathUtil.clamp(threshold, 0, 1);
                  }
  
          }
  
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.