OklabColor.fromList constructor
Constructs an OklabColor from a list of lab
values.
lab
must have exactly 3
or 4
values.
The alpha value, if provided, must be >= 0 && <= 255
.
Implementation
factory OklabColor.fromList(List<double> values) {
assert(values.length == 3 || values.length == 4);
assert(values[0] >= 0.0 && values[0] <= 1.0);
assert(values[1] >= 0.0 && values[1] <= 1.0);
assert(values[2] >= 0.0 && values[2] <= 1.0);
if (values.length == 4) assert(values[3] >= 0 && values[3] <= 255);
final alpha = values.length == 4 ? values[3].round() : 255;
return OklabColor(values[0], values[1], values[2], alpha);
}