Complementary colors?

  • Thread starter Thread starter R. MacDonald
  • Start date Start date
R

R. MacDonald

Hello, Group,

If drawing on a control, it would be desirable to select a colour that
significantly differs from the control's background colour. Is there a
standard (or preferred) way to programmatically select a complementary
color at run time?

Thanks in advance for any suggestions.

Cheers,
Randy
 
I would use the GetBrightness method on the color to determine if it's
closer to black or write, and use the other.

The complementary color could be calculated using:

Color.FromArgb(theColor.ToArgb() xor 0x00ffffff)

That doesn't work for all colors, though. The complementary color for
50% gray is 50% gray...
 
Hello, Göran,

Thanks for the suggestion about GetBrightness. Looking at this I see
that there are also GetHue and GetSaturation methods that I might be
able to apply to this requirement.

Cheers,
Randy
 
Back
Top