MCPcopy Create free account
hub / github.com/cifertech/DisplayKit / isLightColor

Function isLightColor

app.js:1969–1975  ·  view source on GitHub ↗
(hex)

Source from the content-addressed store, hash-verified

1967}
1968
1969function isLightColor(hex) {
1970 const rgb = hexToRgb(hex || "#000000");
1971 if (!rgb) return false;
1972 // Perceived luminance (0..1)
1973 const lum = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
1974 return lum > 0.62;
1975}
1976
1977function getContrastingColor(hex) {
1978 return isLightColor(hex) ? "#111827" : "#FFFFFF";

Callers 3

getContrastingColorFunction · 0.85
addElementFunction · 0.85

Calls 1

hexToRgbFunction · 0.85

Tested by

no test coverage detected