counter-color
Version:
Helps to determine what color of text goes best for a given background, light or dark (and vice versa).
12 lines • 469 B
JavaScript
import { toRGB } from "./rgb";
import { colorLuminance } from "./luminance";
export * from "./luminance";
export * from "./contrast";
export * from "./rgb";
export function counterColor(targetColor, { threshold = 0.35, dark = "#000", light = "#fff" } = {}) {
let rgb = toRGB(targetColor);
const brightness = colorLuminance(rgb);
return brightness > threshold || threshold == 0 ? dark : light;
}
export default counterColor;
//# sourceMappingURL=index.js.map