rgbToHSV function
Implementation
@override
({double h, double s, double v}) rgbToHSV(int r, int g, int b) {
final red = r / 255;
final green = g / 255;
final blue = b / 255;
final max = max3(red, green, blue);
final min = min3(red, green, blue);
final delta = max - min;
final value = max;
final saturation = max == 0 ? 0.0 : (delta / max);
var hue = 0.0;
{
if (delta != 0) {
if (max == red) {
hue = ((green - blue) / delta) % 6;
} else if (max == green) {
hue = ((blue - red) / delta) + 2;
} else {
hue = ((red - green) / delta) + 4;
}
}
hue *= 60;
if (hue < 0) {
hue += 360;
}
}
return (h: hue, s: saturation, v: value);
}