SparrowSharp.Filters.ColorMatrix.AdjustHue C# (CSharp) Method

AdjustHue() public method

Changes the hue. Typical values are in the range [-1, 1].
public AdjustHue ( float hue ) : void
hue float
return void
        public void AdjustHue(float hue)
        {
            hue *= (float)Math.PI;

            float cos = (float)Math.Cos(hue);
            float sin = (float)Math.Sin(hue);

            float[] mtx =
            {
                // r1
                ((LUMA_R + (cos * (1.0f - LUMA_R))) + (sin * -(LUMA_R))),
                ((LUMA_G + (cos * -(LUMA_G))) + (sin * -(LUMA_G))),
                ((LUMA_B + (cos * -(LUMA_B))) + (sin * (1.0f - LUMA_B))),
                0.0f,
                0.0f,

                // r2
                ((LUMA_R + (cos * -(LUMA_R))) + (sin * 0.143f)),
                ((LUMA_G + (cos * (1.0f - LUMA_G))) + (sin * 0.14f)),
                ((LUMA_B + (cos * -(LUMA_B))) + (sin * -0.283f)),
                0.0f,
                0.0f,

                // r3
                ((LUMA_R + (cos * -(LUMA_R))) + (sin * -((1.0f - LUMA_R)))),
                ((LUMA_G + (cos * -(LUMA_G))) + (sin * LUMA_G)),
                ((LUMA_B + (cos * (1.0f - LUMA_B))) + (sin * LUMA_B)),
                0.0f,
                0.0f,

                // r4
                0.0f,
                0.0f,
                0.0f,
                1.0f,
                0.0f
            };

            ConcatMatrix(this, mtx);
        }