Closed babincc closed 1 year ago
Added in 1.1.0 update
Examples:
ColorConverter.xy2rgb(0.5, 0.5); // [255, 222, 0]
ColorConverter.rgb2hsl(255, 0, 0); // [0.0, 1.0, 0.5]
ColorConverter.hsv2hex(0, 1.0 , 1.0); // "ffff0000"
ColorConverter.color2hsv(Color(0xffff0000)); // [0.0, 1.0, 1.0]
ColorConverter.int2rgb(4286611584); // [128, 128, 128]
Also can be used as an extension of Flutter's Color
object
Color myColor = Color(0xff8a4888);
myColor.toXy(); // [0.3209554122773742, 0.21993715851681886, 0.1181557673818057]
myColor.toRgb(); // [138, 72, 136]
myColor.toHex(); // "ff8a4888"
myColor.toInt(); // 4287252616
It would be nice if we could go directly from Flutter Color to ColorXY
. Something like:
final white = ColorXy.fromColor(Colors.white.withOpacity(.5));
final off = ColorXy.fromColor(Colors.transparent);
Add color calculators/converters