HSLuvColor.fromColor constructor
HSLuvColor.fromColor(
- Color color
Creates an HSLuvColor from an RGB Color.
This constructor does not necessarily round-trip with toColor because of floating-point imprecision.
Implementation
factory HSLuvColor.fromColor(Color color) {
final double red = color.red / 0xFF;
final double green = color.green / 0xFF;
final double blue = color.blue / 0xFF;
final List<double> luv = Hsluv.rgbToHsluv([red, green, blue]);
final double hue = luv[0].roundToDouble();
final double saturation = luv[1].roundToDouble();
final double lightness = luv[2].roundToDouble();
return HSLuvColor.fromHSL(hue, saturation, lightness);
}