I am working on a mapping project where captions will be printed over colored regions on a map. Colors come from user selection.
Does anyone have a good algorithm for selecting whether the text should be white or black over a given RGB color?
Currently my best try at it is to add the R, G and B values, then select white or black based on the combined value. (For example: If R+G+B < 225 white, else black.)
This is fairly satifactory, but just wanted to see if anyone had something a little more sophisticated.
Does anyone have a good algorithm for selecting whether the text should be white or black over a given RGB color?
Currently my best try at it is to add the R, G and B values, then select white or black based on the combined value. (For example: If R+G+B < 225 white, else black.)
This is fairly satifactory, but just wanted to see if anyone had something a little more sophisticated.
Comment