luminance static method

double luminance(
  1. int? r,
  2. int? g,
  3. int? b
)

Implementation

static double luminance(int? r, int? g, int? b) {
  final a = [r, g, b].map((it) {
    double value = it!.toDouble() / 255.0;
    return value <= 0.03928
        ? value / 12.92
        : pow((value + 0.055) / 1.055, 2.4);
  }).toList();

  return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
}