Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I am creating a small application to find the complementary color of a color(opposite color using color wheel.checkthis).I searched that.I got 3 steps.
1.Get HSL value of the color.(It is ok using GetHue())
2.Calculate the new H value by rotating 180 degrees.(It is OK)
3.Convert new HSL values into the color.
Now I am on step 3.I have new H,S,L values separately.I need to convert those into a color.Please any body help me.Thank you.
Posted

1 solution

An "oldie" from Bob Powell: [^]: "The conversion of HSL to RGB is a well known algorithm that you can find in numerous places on the web. Oddly enough, down in the bowels of the ControlPaint class, RGB to HSL is employed when you use the ControlPaint.Light(�) or ControlPaint.DarkDark(�) methods but also unfortunately the scaling of the Light, Dark and DarkDark settings are, to say the least, brutal and offer no finesse."

Bob's article has C# code for HSL => RGB.

The EasyRGB web-site is a good professional resource on color-space information: [^].

Adobe products use HSB (aka HSV) color-space, rather than HSL; there is a difference: [^].

Another great resource for color schemes (not from Adobe) is Petr Stanicek's ColorSchemeDesigner: [^], imho a masterpiece of a JavaScript based web-application. This facility does not deal with HSV/B, or HSL, specifically.

There are those who assert .NET's HSL conversion algorithms do not follow the NTSC standards, and are inferior: [^] ... see comments by Itai Bar-Heim, and others.

If what you are after is calculating what color for text overlaid on another color would be most readable (perceptual/relative luminance) given the human eye's greater "weighting" towards perception of green, and lower weighting for perception of blue, etc.: [^].
 
Share this answer
 
Comments
Nelek 5-Nov-13 4:40am    
Nice catch. +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900