topical media & game development

talk show tell print

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

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


  package aether.effects.shaders {
          
          import aether.utils.MathUtil;
  
          public class @ax-graphic-flex-image-effects-07-source-aether-effects-shaders-IsolateColorEffect extends ShaderEffect {
  
                  public static var shaderClass:String = "IsolateColorKernel";
                  public static var shaderFile:String = "isolateColor.pbj";
  
                  private var _red:uint;
                  private var _green:uint;
                  private var _blue:uint;
                  private var _hueThreshold:uint;
                  private var _luminanceThreshold:uint;
                  private var _hideNonIsolated:uint;
                  
                  public function @ax-graphic-flex-image-effects-07-source-aether-effects-shaders-IsolateColorEffect(
                          color:uint=0xFF0000,
                          hueThreshold:uint=10,
                          luminanceThreshold:uint=60,
                          hideNonIsolated:Boolean=false,
                          blendMode:String=null,
                          alpha:Number=1
                  ) {
                          _shaderClass = shaderClass;
                          _shaderFile = shaderFile;
                          this.color = color;
                          this.hueThreshold = hueThreshold;
                          this.luminanceThreshold = luminanceThreshold;
                          this.hideNonIsolated = hideNonIsolated;
                          init(blendMode, alpha);
                  }
                  
                  override protected function configureShader(data:Object):void {
                          data.color.value = [_red, _green, _blue];
                          data.hueThreshold.value =  [hueThreshold];
                          data.luminanceThreshold.value =  [luminanceThreshold];
                          data.hideNonIsolated.value =  [hideNonIsolated];
                  }
                  
                  public function set color(color:uint):void {
                          color = MathUtil.clamp(color, 0, 0xFFFFFF);
                          _red = color >> 16 & 0xFF;
                          _green = color >> 8 & 0xFF;
                          _blue = color & 0xFF;
                  }
  
                  public function set hueThreshold(threshold:uint):void {
                          _hueThreshold = MathUtil.clamp(threshold, 0, 360);
                  }
  
                  public function set luminanceThreshold(threshold:uint):void {
                          _luminanceThreshold = MathUtil.clamp(threshold, 0, 255);
                  }
  
                  public function set hideNonIsolated(hide:Boolean):void {
                          _hideNonIsolated = hide ? 1 : 0;
                  }
  
          }
  
  }


(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.