I have a random colored background, which is divided into solid colored rectangles. I want to draw a grid over the rectangles (this is not a problem). The problem is that due to random colors, I cannot hardcode the color of the mesh, because it may not be displayed.
Another way to think about this is to draw a grid on the surface graph f (x, y). If the color of the grid is the same color of the function (however, it is defined), then it will not be visible.
I would like to take the background color and calculate a new color (shades of gray or a similar background color) that contrasts with the color so that it can be easily seen (but not distract, for example, pure white on black).
I tried using brightness and weighted brightness, but it does not work well for all colors. I also tried gamma color correction, but it also does not work.
I would also like the mesh color to be as uniform as possible (I could calculate the adjacent mesh colors for blending). This is not so important, but it would be nice to have some uniformity.
The code I'm working with is based on
byte I = (byte)(Math.Max(Bar.Background.R, Math.Max(Bar.Background.G, Bar.Background.B)));
if (I < 120)
I = (byte)(I + 30);
else
I = (byte)(I - 30);
I also tried rgb gamma correction.
Does anyone have any ideas?
source
share