 
       matrix = temp;
     }
-
-    public function rotateRed( degrees:Number ):void {
-      rotateColor( degrees, 2, 1 );
-    }
-
-    public function rotateGreen( degrees:Number ):void {
-      rotateColor( degrees, 0, 2 );
-    }
-
-    public function rotateBlue( degrees:Number ):void {
-       rotateColor( degrees, 1, 0 );
-    }
-
-    private function rotateColor( degrees:Number, x:int, y:int ):void {
-      degrees *= RAD;
-      var mat:Array = IDENTITY.concat();
-      mat[ x + x * 5 ] = mat[ y + y * 5 ] = Math.cos( degrees );
-      mat[ y + x * 5 ] = Math.sin( degrees );
-      mat[ x + y * 5 ] = -Math.sin( degrees );
-      concat( mat );
-    }
-
-    public function shearRed( green:Number, blue:Number ):void {
-      shearColor( 0, 1, green, 2, blue );
-    }
-
-    public function shearGreen( red:Number, blue:Number ):void {
-      shearColor( 1, 0, red, 2, blue );
-    }
-
-    public function shearBlue( red:Number, green:Number ):void {
-      shearColor( 2, 0, red, 1, green );
-    }
-
-    private function shearColor( x:int, y1:int, d1:Number, y2:int, d2:Number ):void {
-      var mat:Array = IDENTITY.concat();
-      mat[ y1 + x * 5 ] = d1;
-      mat[ y2 + x * 5 ] = d2;
-      concat( mat );
-    }
-
-    public function applyColorDeficiency( type:String ):void {
-      // the values of this method are copied from http://www.nofunc.com/Color_Matrix_Library/
-      switch( type ) {
-        case 'Protanopia':
-          concat( [ 0.567, 0.433, 0, 0, 0, 0.558, 0.442, 0, 0, 0,
-                    0, 0.242, 0.758, 0, 0, 0, 0, 0, 1, 0 ] );
-          break;
-        case 'Protanomaly':
-          concat( [ 0.817, 0.183, 0, 0, 0, 0.333, 0.667, 0, 0, 0,
-                    0, 0.125, 0.875, 0, 0, 0, 0, 0, 1, 0 ] );
-          break;
-        case 'Deuteranopia':
-          concat( [ 0.625, 0.375, 0, 0, 0, 0.7, 0.3, 0, 0, 0,
-                    0, 0.3, 0.7, 0, 0, 0, 0, 0, 1, 0 ] );
-          break;
-        case 'Deuteranomaly':
-          concat( [ 0.8, 0.2, 0, 0, 0, 0.258, 0.742, 0, 0, 0,
-                    0, 0.142, 0.858, 0, 0, 0, 0, 0, 1, 0 ] );
-          break;
-        case 'Tritanopia':
-          concat( [ 0.95, 0.05, 0, 0, 0, 0, 0.433, 0.567, 0, 0,
-                    0, 0.475, 0.525, 0, 0, 0, 0, 0, 1, 0 ] );
-          break;
-        case 'Tritanomaly':
-          concat( [ 0.967, 0.033, 0, 0, 0, 0, 0.733, 0.267, 0, 0,
-                    0, 0.183, 0.817, 0, 0, 0, 0, 0, 1, 0 ] );
-          break;
-        case 'Achromatopsia':
-            concat( [ 0.299, 0.587, 0.114, 0, 0, 0.299, 0.587, 0.114, 0, 0,
-                      0.299, 0.587, 0.114, 0, 0, 0, 0, 0, 1, 0 ] );
-            break;
-        case 'Achromatomaly':
-          concat( [ 0.618, 0.320, 0.062, 0, 0, 0.163, 0.775, 0.062, 0, 0,
-                    0.163, 0.320, 0.516, 0, 0, 0, 0, 0, 1, 0 ] );
-          break;
-      }
-    }
-
-    public function applyMatrix( rgba:uint ):uint {
-      var a:Number = ( rgba >>> 24 ) & 0xff;
-      var r:Number = ( rgba >>> 16 ) & 0xff;
-      var g:Number = ( rgba >>> 8 ) & 0xff;
-      var b:Number = rgba & 0xff;
-
-      var r2:int = 0.5 + r * matrix[0] + g * matrix[1] +
-                         b * matrix[2] + a * matrix[3] + matrix[4];
-      var g2:int = 0.5 + r * matrix[5] + g * matrix[6] +
-                         b * matrix[7] + a * matrix[8] + matrix[9];
-      var b2:int = 0.5 + r * matrix[10] + g * matrix[11] +
-                         b * matrix[12] + a * matrix[13] + matrix[14];
-      var a2:int = 0.5 + r * matrix[15] + g * matrix[16] +
-                         b * matrix[17] + a * matrix[18] + matrix[19];
-
-      if( a2 < 0 )   a2 = 0;
-      if( a2 > 255 ) a2 = 255;
-      if( r2 < 0 )   r2 = 0;
-      if( r2 > 255 ) r2 = 255;
-      if( g2 < 0 )   g2 = 0;
-      if( g2 > 255 ) g2 = 255;
-      if( b2 < 0 )   b2 = 0;
-      if( b2 > 255 ) b2 = 255;
-
-      return a2 << 24 | r2 << 16 | g2 << 8 | b2;
-    }
-
-    public function transformVector( values:Array ):void {
-      if( values.length != 4 ) return;
-
-      var r:Number = values[0] * matrix[0] + values[1] * matrix[1] +
-                     values[2] * matrix[2] + values[3] * matrix[3] + matrix[4];
-      var g:Number = values[0] * matrix[5] + values[1] * matrix[6] +
-                     values[2] * matrix[7] + values[3] * matrix[8] + matrix[9];
-      var b:Number = values[0] * matrix[10] + values[1] * matrix[11] +
-                     values[2] * matrix[12] + values[3] * matrix[13] + matrix[14];
-      var a:Number = values[0] * matrix[15] + values[1] * matrix[16] +
-                     values[2] * matrix[17] + values[3] * matrix[18] + matrix[19];
-
-      values[0] = r;
-      values[1] = g;
-      values[2] = b;
-      values[3] = a;
-    }
-
-    private function initHue():void {
-      //var greenRotation:Number = 35.0;
-      var greenRotation:Number = 39.182655;
-
-      if( !hueInitialized ) {
-        hueInitialized = true;
-        preHue = new ColorMatrix();
-        preHue.rotateRed( 45 );
-        preHue.rotateGreen( -greenRotation );
-
-        var lum:Array = [ LUMA_R2, LUMA_G2, LUMA_B2, 1.0 ];
-
-        preHue.transformVector( lum );
-
-        var red:Number = lum[0] / lum[2];
-        var green:Number = lum[1] / lum[2];
-
-        preHue.shearBlue( red, green );
-
-        postHue = new ColorMatrix();
-        postHue.shearBlue( -red, -green );
-        postHue.rotateGreen( greenRotation );
-        postHue.rotateRed( -45.0 );
-      }
-    }
   }
 }

          0, 1, 0, 0, g,
          0, 0, 1, 0, b,
          0, 0, 0, 1, 0 ]
      );
    }

    public function adjustHue( degrees:Number ):void {
      degrees *= RAD;
      var cos:Number = Math.cos( degrees );
      var sin:Number = Math.sin( degrees );

      concat(
        [ ((LUMA_R + (cos * (1 - LUMA_R))) + (sin * -(LUMA_R))),
          ((LUMA_G + (cos * -(LUMA_G))) + (sin * -(LUMA_G))),
          ((LUMA_B + (cos * -(LUMA_B))) + (sin * (1 - LUMA_B))),
          0, 0,

          ((LUMA_R + (cos * -(LUMA_R))) + (sin * 0.143)),
          ((LUMA_G + (cos * (1 - LUMA_G))) + (sin * 0.14)),
          ((LUMA_B + (cos * -(LUMA_B))) + (sin * -0.283)),
          0, 0,

          ((LUMA_R + (cos * -(LUMA_R))) + (sin * -((1 - LUMA_R)))),
          ((LUMA_G + (cos * -(LUMA_G))) + (sin * LUMA_G)),
          ((LUMA_B + (cos * (1 - LUMA_B))) + (sin * LUMA_B)),
          0, 0,

          0, 0, 0, 1, 0 ]
      );
    }

    public function rotateHue( degrees:Number ):void {
      initHue();

      concat( preHue.matrix );
      rotateBlue( degrees );
      concat( postHue.matrix );
    }

    public function luminance2Alpha():void {
      concat(
        [ 0, 0, 0, 0, 255,
          0, 0, 0, 0, 255,
          0, 0, 0, 0, 255,
          LUMA_R, LUMA_G, LUMA_B, 0, 0 ]
      );
    }

    public function adjustAlphaContrast( amount:Number ):void {
      amount += 1;
      concat(
        [ 1, 0, 0, 0, 0,
          0, 1, 0, 0, 0,
          0, 0, 1, 0, 0,
          0, 0, 0, amount, (128 * (1 - amount)) ]
      );
    }


      );
    }

    public function adjustBrightness( r:Number, g:Number=NaN, b:Number = NaN ):void {
      if( isNaN( g ) ) { g = r; }
      if( isNaN( b ) ) { b = r; }
