topical media & game development

talk show tell print

#graphic-flex-image-effects-07-source-aether-effects-texture-NoiseEffect.ax

#graphic-flex-image-effects-07-source-aether-effects-texture-NoiseEffect.ax [swf] [flash] flex


  package aether.effects.texture {
          
          import aether.effects.ImageEffect;
  
          import flash.display.BitmapData;
          import flash.display.BlendMode;
          import flash.geom.ColorTransform;
          import flash.geom.Matrix;
          
          public class @ax-graphic-flex-image-effects-07-source-aether-effects-texture-NoiseEffect extends ImageEffect {
          
                  private var _strength:Number;
  
                  public function @ax-graphic-flex-image-effects-07-source-aether-effects-texture-NoiseEffect(strength:Number=1, blendMode:String=null, alpha:Number=1) {
                          init(blendMode, alpha);
                          _strength = strength;
                  }
          
                  override protected function applyEffect(bitmapData:BitmapData):void {
                          var noise:BitmapData = new BitmapData(bitmapData.width, bitmapData.height, true, 0x00000000);
                          noise.fillRect(noise.rect, 0xFFFFFF);
                          var seed:uint = (Math.random()*1000)|0;
                          noise.noise(seed, 0, 255, 1, true);
                          var colorTransform:ColorTransform = new ColorTransform(1, 1, 1, _strength, 0, 0, 0, 0);
                          bitmapData.draw(noise, new Matrix(), colorTransform, BlendMode.MULTIPLY);
                  }
          
          }
          
  }


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