MCPcopy Create free account
hub / github.com/microsoft/SandDance / luminance

Function luminance

docs/app/js/sanddance-app.js:142916–142919  ·  view source on GitHub ↗
(color)

Source from the content-addressed store, hash-verified

142914 return Math.pow((val + 0.055) / 1.055, 2.4);
142915}
142916function luminance(color) {
142917 const c = (0, _d3Color.rgb)(color), r = channel_luminance_value(c.r), g = channel_luminance_value(c.g), b = channel_luminance_value(c.b);
142918 return 0.2126 * r + 0.7152 * g + 0.0722 * b;
142919} // https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
142920function contrast(color1, color2) {
142921 const lum1 = luminance(color1), lum2 = luminance(color2), lumL = Math.max(lum1, lum2), lumD = Math.min(lum1, lum2);
142922 return (lumL + 0.05) / (lumD + 0.05);

Callers 1

contrastFunction · 0.70

Calls 1

channel_luminance_valueFunction · 0.70

Tested by

no test coverage detected