|
|
|
|
|
|
if (max == 0.0f || delta == 0.0f) { |
|
|
|
hue = 0.0f; |
|
|
|
} |
|
|
|
else if (max == red) { |
|
|
|
else if (Math.Abs(max - red) < foundation_.precisionErrorTolerance) { |
|
|
|
else if (max == green) { |
|
|
|
else if (Math.Abs(max - green) < foundation_.precisionErrorTolerance) { |
|
|
|
else if (max == blue) { |
|
|
|
else if (Math.Abs(max - blue) < foundation_.precisionErrorTolerance) { |
|
|
|
hue = 60.0f * (((red - green) / delta) + 4); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static HSVColor fromColor(Color color) { |
|
|
|
float red = color.red / 0xFF; |
|
|
|
float green = color.green / 0xFF; |
|
|
|
float blue = color.blue / 0xFF; |
|
|
|
float red = (float)color.red / 0xFF; |
|
|
|
float green = (float)color.green / 0xFF; |
|
|
|
float blue = (float)color.blue / 0xFF; |
|
|
|
float alpha = color.alpha / 0xFF; |
|
|
|
float alpha = (float)color.alpha / 0xFF; |
|
|
|
float hue = painting_._getHue(red, green, blue, max, delta); |
|
|
|
float saturation = max == 0.0f ? 0.0f : delta / max; |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static HSLColor fromColor(Color color) { |
|
|
|
float red = color.red / 0xFF; |
|
|
|
float green = color.green / 0xFF; |
|
|
|
float blue = color.blue / 0xFF; |
|
|
|
float red = (float)color.red / 0xFF; |
|
|
|
float green = (float)color.green / 0xFF; |
|
|
|
float blue = (float)color.blue / 0xFF; |
|
|
|
float alpha = color.alpha / 0xFF; |
|
|
|
float alpha = (float)color.alpha / 0xFF; |
|
|
|
float saturation = lightness == 1.0f |
|
|
|
float saturation = Math.Abs(lightness - 1.0f) < foundation_.precisionErrorTolerance |
|
|
|
? 0.0f |
|
|
|
: ((delta / (1.0f - Mathf.Abs(2.0f * lightness - 1.0f))).clamp(0.0f, 1.0f)); |
|
|
|
return HSLColor.fromAHSL(alpha, hue, saturation, lightness); |
|
|
|