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); }
public static (double hue, double saturation, double value, double alpha) RGBAColorToHSVAColor1(byte red, byte green, byte blue, byte alpha) { var max = Max3Double.Max(red, green, blue); var min = Min3DoubleTests.Min(red, green, blue); var hue = GetHueFromRGBByteTests.GetHue(red, green, blue); var saturation = (max == 0) ? 0 : 1d - (1d * min / max); var value = max / 255d; return(hue, saturation, value, alpha / 255d); }