toLABColor method
Implementation
LABColor toLABColor() {
double x1(double v) => v > .04045 ? math.pow((v + .055) / 1.055, 2.4) as double : v / 12.92;
double x2(a) {
const b = 6 / 29;
final c = 1 / (3 * math.pow(b, 2));
return (a > math.pow(b, 3) ? math.pow(a, 1 / 3) : c * a + 4 / 29) as double;
}
final xR = x1(red);
final xG = x1(green);
final xB = x1(blue);
final xE = .2126729 * xR + .7151522 * xG + .0721750 * xB;
return LABColor.fromALAB(
alpha,
116 * x2(xE) - 16,
500 * (x2((.4124564 * xR + .3575761 * xG + .1804375 * xB) / .95047) - x2(xE)),
200 * (x2(xE) - x2((.0193339 * xR + .1191920 * xG + .9503041 * xB) / 1.08883)));
}