color-fns
Version:
Modern JavaScript color utility library.
16 lines • 663 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* https://www.w3.org/TR/WCAG20/#relativeluminancedef
*/
function relativeLuminance(value) {
var sR = value.red / 255;
var sG = value.green / 255;
var sB = value.blue / 255;
var R = sR <= 0.03928 ? (sR / 12.92) : (Math.pow(((sR + 0.055) / 1.055), 2.4));
var G = sG <= 0.03928 ? (sG / 12.92) : (Math.pow(((sG + 0.055) / 1.055), 2.4));
var B = sB <= 0.03928 ? (sB / 12.92) : (Math.pow(((sB + 0.055) / 1.055), 2.4));
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
}
exports.relativeLuminance = relativeLuminance;
//# sourceMappingURL=relativeLuminance.js.map