C # Best way to darken a color before reading it

What is the best way to darken a color until it becomes readable? I have a series of titles that have the appropriate color, but some of these colors are very light, and any text drawn in them is unreadable. I talked to HSB and it seems like I can't get an algorithm that dims the color without making it look silver.

I basically just did this, but it doesn't seem to be 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 also want to change the saturation. Is there a standard way to do this?

+6
source share
1 answer

I basically just hacked into a randomizer that adds components to RGB values ​​if the sum of the RGB values ​​is too low or any one element is too low. This is a non-standard way to do this, but it seems to give good results.

 double threshold = .8; for (int j = 0; j < 3; j++) { if (color.GetBrightness() > threshold) { color[j] -= new MyRandom(0, 20/255); } } 
+1
source

Source: https://habr.com/ru/post/907137/


All Articles