I have 60% Opaque form. And when the user changes the color of the form, sometimes (depending on the chosen color), they cannot see the text on the form anymore because it too-closely resembles the color of the form. So, I'm trying to do maybe an if/switch to see if the chosen BackColor of the form is either Dark, or Light. If it is Dark, then all text on the form should be White. If it is Light, then all text on the form should be Black.
Is this at all possible? I've seen this all over the place but not sure what to search for without writing the whole question in the search field.
Any help/suggestions would be greatly appreciated.
Thanks, jason.
Black backgrounds: High-chroma colors are best for black backgrounds because they offer a good contrast ratio without the eye fatigue (which occurs with white text on a black background).
While white text on a black background provides very high value contrast, it is less readable and causes greater eye fatigue than black text on a white background.
It'll reflect less light, making it easier to read. Keep in mind that if you're reading text in a dark room where no light is present, white text on a black background isn't as hard to read. This is because no light is reflecting off it in a dark room.
Pure black isn't harmful to all users. Low vision users, who are sight impaired but not blind, tend to read text better with pure black text or white text on a black background. When designing for them, you may need to use black for an accessibility mode.
How about using Color.GetBrightness()
to work out how light it is?
You could check, if the sum of the three rgb-values are above the half of the max-value
-> because 255,255,255 == white(light) and 0,0,0 == black(dark) :
f.e.
R 255
G 140
B 170
=====
565
Max: 765 (Middle 382) Sum: 565
Because the sum is 565 and above the middle (dark < 382 < light), the color is light. So you can change the textcolor to dark.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With