(hex)
| 1967 | } |
| 1968 | |
| 1969 | function 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 | |
| 1977 | function getContrastingColor(hex) { |
| 1978 | return isLightColor(hex) ? "#111827" : "#FFFFFF"; |
no test coverage detected