Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine Contrasting/Inverse Colors
Message
From
23/05/2009 12:40:16
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
22/05/2009 19:41:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01401618
Message ID:
01401660
Views:
59
This message has been marked as a message which has helped to the initial question of the thread.
>I need to be able to determine the forecolor when a user selects the backcolor. This is to be able to display the text as readable based on what the backcolor is. Just taking the inverse color works for the outer color spectrum but when it is in the middle this does not work well.
>
>Does anyone have any ideas on how to calculate the best readable forecolor based on the backcolor setting? Thanks.

Inverse color is the easiest thing to do: bitxor(nColor, 0xffffff), but the inverse of #808080 is #7f7f7f, which looks pretty much the same. IOW, any color that's close to the middle (and #808080 and #7f7f7f aren't colors at all - they are grays) will have an inverse that's just as close to the middle, and the distance between such a color and its inverse in the color space may fall below any readability standard.

So if the solution that Tracy posted looks like a cheap way out (the result is again not a color, but a black or a white), it's actually the best way out. In many cases you actually don't want the contrary color, because it would wear and (literally?) tear the eyes of the user. While it may help some of them, it may irritate others. So I'd go with that simple black and white answer to this color question.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform