getColorFromCielab static method

int getColorFromCielab(
  1. double l,
  2. double a,
  3. double b,
  4. double opacity,
)

Implementation

static int getColorFromCielab(double l, double a, double b, double opacity) {
  final Map<String, double> xyz = {
    'x': a / 500 + (l + 16) / 116,
    'y': (l + 16) / 116,
    'z': (l + 16) / 116 - b / 200
  };

  xyz.forEach((key, value) {
    final cube = pow(value, 3);
    if (cube > 0.008856) {
      xyz[key] = cube as double;
    } else {
      xyz[key] = (value - 16 / 116) / 7.787;
    }
    xyz[key] = xyz[key]! * _white[key]!;
  });

  return XyzColor.getColorFromXyz(xyz['x']!, xyz['y']!, xyz['z']!, opacity);
}