HSVColor.fromColor constructor
HSVColor.fromColor(
- Color color
Creates an HSVColor from an RGB Color.
This constructor does not necessarily round-trip with toColor because of floating point imprecision.
Implementation
factory HSVColor.fromColor(Color color) {
var red = color.red / 0xFF;
var green = color.green / 0xFF;
var blue = color.blue / 0xFF;
var max = math.max(red, math.max(green, blue));
var min = math.min(red, math.min(green, blue));
var delta = max - min;
var alpha = color.alpha / 0xFF;
var hue = _getHue(red, green, blue, max, delta);
var saturation = max == 0.0 ? 0.0 : delta / max;
return HSVColor.fromAHSV(alpha, hue, saturation, max);
}