Change the text color into white on dark backgrounds

Very often the text (eg. in the calendar) ist black on a dark color:


I wrote a function (PHP) for my CMS based on the human eyes:

if (((($color[‘red’] * 299) + ($color[‘green’] * 587) + ($color[‘blue’] * 114)) / 1000) < 140) $isdark=1; else $isdark=0;

The values of RGB are 0 to 255.
If the background color is dark for humans you have to use white text color on it.

We already use an appropriate colour automatically depending on the background. If you have a very dark background, the text will be a light colour. If you have a very light background, the text will be a dark colour.

I know but it doesn’t work as well as my function works as you can see in my screenshot. Maybe it is ok for you but my function is based on science and works very well since many years for all of my clients.

Your screenshot looks just fine. It is very readable having dark text on a lighter background. :+1:

Maybe it depends on the brightness of your and my monitors.
Yes, the screenshot is principle readably, but it is not easy to read.