computeLuminance method

double computeLuminance()

Returns a brightness value between 0 for darkest and 1 for lightest.

Represents the relative luminance of the color. This value is computationally expensive to calculate.

See en.wikipedia.org/wiki/Relative_luminance.

Implementation

double computeLuminance() {
  assert(colorSpace != ColorSpace.extendedSRGB);
  // See <https://www.w3.org/TR/WCAG20/#relativeluminancedef>
  final double R = _linearizeColorComponent(r);
  final double G = _linearizeColorComponent(g);
  final double B = _linearizeColorComponent(b);
  return 0.2126 * R + 0.7152 * G + 0.0722 * B;
}