Measuring the luminosity or lightness in a color

While preparing my css templates, I find sometimes that the color I am working on needs a dark background or a light background to enhance readability.

So, how do you find out if the color you have reaches the luminosity threshold?

Use math! You can take the Hex code of the color and play with it. You can find a simple javascript code to do it here: http://stackoverflow.com/questions/12043187/how-to-check-if-hex-color-is-too-black

And an explanation of what lum is, in Wikipedia: http://en.wikipedia.org/wiki/Rec._709#Luma_coefficients

2 thoughts on “Measuring the luminosity or lightness in a color

Leave a comment