/ coding

Hugo Giraudel's Color Clock Experiment

Speaking of time, here’s a nice JavaScript experiment that changes the background color of a clock every second. Of particular interest to me was the note about changing the text color based on the luminance of the background color:

Last but not least, we need to find a way to change the font color if the background color is too dark or too light, so the text remains readable at all time. To do this, we have to compute the luminance of a color. If it is higher than .7, then the color is very bright and text should be black.

I wonder if .7 is a well-known hard-and-fast rule for determining when to switch to dark text, or if that’s just a ballpark number.