luminance function

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

Implementation

double luminance(int r, int g, int b) {
  double f(int v) {
    v = v.clamp(0, 255);
    final x = v / 255;
    return x <= 0.03928 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4).toDouble();
  }
  return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
}