Closed unional closed 7 years ago
@yajurvendrasinh I like the contrast idea a lot. How can we generate the right color based on the background color?
i.e.:
function createContrastColor(/* background */ color: Color, contrast: number) {
// ...
}
Info about contrast ratio: https://www.w3.org/TR/WCAG/#contrast-ratiodef https://www.w3.org/TR/WCAG/#relativeluminancedef
And video on contrast ratio: https://youtu.be/LBmLspdAtxM thanks @yajurvendrasinh
Some great points added. One way to find the contrast color based on the background would be to calculate the luminance (L = 0.2126*R + 0.7152 * G + 0.0722 * B)
. If the luminance is lower than 200 (darker background, we make the text lighter). I will create a PR to demonstrate. We could also possibly calculate the contrast ratio of foreground/background based on the standards and generate text colors whose ratio is higher than 4.5:1
.
Closed by #4
Currently, some color combinations make the text hard to read. Need to optimize it a bit.
Here are some ideas: