computeLuminance method
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.
Implementation
double computeLuminance() {
// See <https://www.w3.org/TR/WCAG20/#relativeluminancedef>
var R = _linearizeColorComponent(red / 0xFF);
var G = _linearizeColorComponent(green / 0xFF);
var B = _linearizeColorComponent(blue / 0xFF);
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
}