public static (double hue, double saturation, double intensity, double alpha) RGBAFColorToHSIAColor1(double red, double green, double blue, double alpha)
        {
            (double hue, double saturation, double intensity, double alpha)color = (0d, 0d, 0d, alpha);
            var m = Min3DoubleTests.Min(red, green, blue);
            var M = Max3Double.Max(red, green, blue);
            var c = M - m;

            if (ValidateRGBAFloatTests.ValidateRGBAF(red, green, blue, alpha) == true)
            {
                color.intensity = 1d / 3d * (red + green + blue);
                if (c == 0)
                {
                    color.hue        = 0d;
                    color.saturation = 0d;
                }
                else
                {
                    if (M == red)
                    {
                        color.hue = IEEERemainder((green - blue) / c, 6d);
                    }
                    else if (M == green)
                    {
                        color.hue = ((blue - red) / c) + 2d;
                    }
                    else if (M == blue)
                    {
                        color.hue = ((red - green) / c) + 4d;
                    }
                    color.hue       *= 60d;
                    color.saturation = 1d - (m / color.intensity);
                }
            }
            return(color);
        }
 public static (double hue, double saturation, double value, double alpha) RGBAFColorToHSVAColor1(double red, double green, double blue, double alpha)
 {
     (double hue, double saturation, double value, double alpha)color = (0d, 0d, 0d, alpha);
     if (ValidateRGBAFloatTests.ValidateRGBAF(red, green, blue, alpha) == true)
     {
         var M = Max3Double.Max(red, green, blue);
         var m = Min3DoubleTests.Min(red, green, blue);
         var c = M - m;
         color.value = M;
         if (c != 0d)
         {
             if (M == red)
             {
                 color.hue = IEEERemainder((green - blue) / c, 6d);
             }
             else if (M == green)
             {
                 color.hue = ((blue - red) / c) + 2d;
             }
             else /*if(M==b)*/
             {
                 color.hue = ((red - green) / c) + 4d;
             }
             color.hue       *= 60d;
             color.saturation = c / color.value;
         }
     }
     return(color);
 }
Exemple #3
0
        public static (double y, double i, double q, double alpha) RGBAFColorToYIQAColor1(double red, double green, double blue, double alpha)
        {
            if (!ValidateRGBAFloatTests.ValidateRGBAF(red, green, blue, alpha))
            {
                throw new ArgumentOutOfRangeException("A parameter is out of range.");
            }

            return(
                y : (0.299900d * red) + (0.587000d * green) + (0.114000d * blue),
                i : (0.595716d * red) - (0.274453d * green) - (0.321264d * blue),
                q : (0.211456d * red) - (0.522591d * green) + (0.311350d * blue),
                alpha
                );
        }
Exemple #4
0
        public static (byte red, byte green, byte blue, byte alpha) RGBAFColorToRGBAColor1(double red, double green, double blue, double alpha)
        {
            if (!ValidateRGBAFloatTests.ValidateRGBAF(red, green, blue, alpha))
            {
                throw new ArgumentOutOfRangeException("A parameter is out of range.");
            }

            var d = RGBMax + 0.5d;

            return(
                red : (byte)(red * d),
                green : (byte)(green * d),
                blue : (byte)(blue * d),
                alpha : (byte)(alpha * d)
                );
        }
        public static (double y, double u, double v, double alpha) RGBAFColorToYUVAColor1(double red, double green, double blue, double alpha)
        {
            if (!ValidateRGBAFloatTests.ValidateRGBAF(red, green, blue, alpha))
            {
                throw new ArgumentOutOfRangeException("A parameter is out of range.");
            }

            var y = (0.299d * red) + (0.587d * green) + (0.114d * blue);

            return(
                y,
                u : 0.492d * (blue - y), // u: 0.565 * (b - y),
                v : 0.877d * (red - y),  // v: 0.713d * (r - y)
                alpha
                );
        }