0

Say I have two colors, red and pink. How would I define a relationship between them such that I would be able to use it to get say, light blue from blue? The 'pink' isn't just light red, so I don't want to use ControlPaint.Light. The easiest way I can think of is to get the HSB difference between red and pink and just add that to the base blue color, but c# lacks methods to convert those HSB values back to RGB and I would rather not write my own if I can help it. Is there another way?

idlackage
  • 2,715
  • 8
  • 31
  • 52
  • If you don't want to write own code, just use [existing code](http://stackoverflow.com/questions/4123998/algorithm-to-switch-between-rgb-and-hsb-color-values) – Nico Schertler Sep 30 '13 at 18:10
  • @NicoSchertler I would like to use as little non-native code as possible--essentially I'd like to know if there's a way beside the one I posted to do this. – idlackage Sep 30 '13 at 18:11
  • What's non-native about the code the Nico linked to? – Chris Dunaway Sep 30 '13 at 19:36

1 Answers1

1

If you want to adjust the lightness of a color without changing the hue, your best option is to convert the RGB color to HSL. Then adjust the lightness by a certain amount. Then convert it back to RGB if needed.

You can find a lot of examples of code to use to do the conversion such as the following:

Convert RGB bytes to HSL and back?

Community
  • 1
  • 1
Trevor Elliott
  • 11,292
  • 11
  • 63
  • 102