A color matrix class containing an array of 20 floats arranged as a 4x5 matrix.
示例#1
0
        private void AddTestObjects(int numObjects)
        {
            int border = 15;

            Random r = new Random();
            for (int i = 0; i < numObjects; ++i)
            {   
                Image egg = new Image(textures[0]);
                if (i < 5)
                {
                    ColorMatrix cm = new ColorMatrix();
                    cm.AdjustSaturation(-0.8f);
                    ColorMatrixFilter fi = new ColorMatrixFilter (cm);
                    //EmptyFilter fi = new EmptyFilter();
                    //BlurFilter fi = new BlurFilter(4, 1.1f);
                    egg.Filter = fi;
                    //egg.Filter.Cache();
                }
                //MovieClip egg = new MovieClip (textures, 3);
                //SP.DefaultJuggler.Add (egg);
                egg.X = r.Next(border, (int)Stage.Width - border);
                egg.Y = r.Next(border, (int)Stage.Height - border);
                egg.Rotation = (float)(r.Next(0, 100) / 100.0f * Math.PI);
                _container.AddChild(egg);
            }

            Sprite sp = new Sprite();
            sp.X = sp.Y = 250;
            _container.AddChild(sp);

            Image test = new Image(textures[1]);
            test.PivotX = test.PivotY = test.Width / 2;
            sp.AddChild(test);

            Image test1 = new Image(textures[1]);
            sp.AddChild(test1);
            test1.X = test1.Y = 60;
        }
 public ColorMatrixFilter(ColorMatrix matrix = null)
 {
     this.ColorMatrix = matrix ?? new ColorMatrix();
     _colorMatrixDirty = true;
 }
 /// <summary>
 /// Concatenates the current matrix with another one.
 /// </summary>
 public void ConcatColorMatrix(ColorMatrix colorMatrix)
 {
     this.ColorMatrix.ConcatColorMatrix(colorMatrix);
     _colorMatrixDirty = true;
 }
示例#4
0
 private void ConcatMatrix(ColorMatrix target, float[] source)
 {
     int i = 0;
     float[] temp = new float[20];
     for (int y = 0; y < 4; ++y)
     {
         for (int x = 0; x < 5; ++x)
         {
             temp[i + x] = source[i] * target._m[x] +
             source[i + 1] * target._m[x + 5] +
             source[i + 2] * target._m[x + 10] +
             source[i + 3] * target._m[x + 15] + (x == 4 ? source[i + 4] : 0);
         }
         i += 5;
     }
     target._m = temp;
 }
示例#5
0
 /// <summary>
 /// Concatenates the receiving color matrix with another one.
 /// </summary>
 public void ConcatColorMatrix(ColorMatrix colorMatrix)
 {
     ConcatMatrix(this, colorMatrix._m);
 }
 /// <summary>
 /// Creates a color matrix filter wit the specified color matrix.
 /// If the matrix is not specified it will use an identity matrix 
 /// (that does nothing)
 /// </summary>
 public static ColorMatrixFilter ColorMatrix(ColorMatrix colorMatrix = null)
 {
     return new ColorMatrixFilter(colorMatrix);
 }