Whats the best way to darken a color until it is readable? I have a series of titles are have an associated color, but some of these colors are very light and any text drawn in them is unreadable. I've been messing around with HSB and I can't seem to get an algorithm down that darkens the color without making it look silverish.
I've basically just been doign this, but it doesn't seem to get what I would call "good" results:
Color c =
FromHSB(
orig.A,
orig.GetHue(),
orig.GetSaturation(),
orig.GetBrightness() > .9 ?
orig.GetBrightness() - MyClass.Random(.5, .10)
: orig.GetBrightness());
I think I want to alter the saturation too. Is there a standard way of doing this?
I basically just hacked together a randomizer that adds components to the RGB values if the sum of the RGB values is too low, or any one item is too low. Its a non-rigourous way to do it, but it seems to produce good results.
double threshold = .8;
for (int j = 0; j < 3; j++)
{
if (color.GetBrightness() > threshold)
{
color[j] -= new MyRandom(0, 20/255);
}
}
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