1

I want to get the complementary color of an hexadecimal color in C. From what I understood I need to first convert it to HSL and then change the angles. But how can I do this conversion? Is that any other way to get the complementary?

joana
  • 23
  • 3
  • Try searching for `[c] hsl` here on SO. – user3386109 Jan 02 '19 at 09:00
  • 2
    There is not a single definition for "complementary colors", several contradicting methods exist. Simply inverting the RGB colors bitwise for example is a perfectly valid method. In general, it's the opposite color of a "color wheel", but how this wheel is exactly constructed is to the disposition of the "artist" – Ctx Jan 02 '19 at 09:07
  • @ctx, the color wheel is constructed by placing the three primay colors on a circle and then gradually changing the color(s) in between. Nothing is left to the artist, except for maybe the number of steps (bits?) in between. – Paul Ogilvie Jan 02 '19 at 09:26
  • @PaulOgilvie Already the definition, what the primary colors are (RYB or RGB) differs. But there are even more possibilities to vary the color wheel, ask google. – Ctx Jan 02 '19 at 09:37
  • @Ctx, in computes (i.e. displays) we use the additive RGB colors (additive. i.e. light emitting). In subtractive colors (i.e. reflecting from a surface) the primary colors as used in e.g. printing are CYMK, also on a color wheel of which there is only one way to construct it. RYB are part of the subtractive color wheel, not the additive RGB. – Paul Ogilvie Jan 02 '19 at 10:03
  • @PaulOgilvie I do not see why computer monitors play a role here. Just because you are staring at one right now? What does this have to do with color theory? A monitor tries to display a color as accurate as possible, regardless of the color model. There might be subtractive displays (i.e. E-paper displays etc), which will try to print exactly the same color for the same hex value, regardless of its fundamental technology. – Ctx Jan 02 '19 at 10:11
  • Possible duplicate of [How to convert RGB to HSL in C?](https://stackoverflow.com/questions/12380682/how-to-convert-rgb-to-hsl-in-c) – Billy Brown Jan 02 '19 at 11:40

0 Answers0