toHSV method
Implementation
List<double> toHSV() {
var rgb = toIntRGB();
var max_ = rgb.reduce(max);
var min_ = rgb.reduce(min);
var d = max_ - min_;
var h = 0.0;
var s = (max_ == 0 ? 0.0 : d / max_);
var v = max_ / 255;
var r = rgb[0]; // from 0 to 255
var g = rgb[1]; // from 0 to 255
var b = rgb[2]; // from 0 to 255
if (max_ == min_) {
h = 0.0;
} else if (max_ == r) {
h = ((g - b) + d * (g < b ? 6 : 0)) / (6 * d);
} else if (max_ == g) {
h = ((b - r) + d * 2) / (6 * d);
} else if (max_ == b) {
h = ((r - g) + d * 4) / (6 * d);
}
return [h, s, v];
}