views:

623

answers:

2

I have a color and I want get a tint of that color by a certain percent. So 100% is the color itself, 90% is a slightly lighter color, etc. Basically, it's like adding 10% of opacity to the color, if the color is on a white background. I need to convert the color into a hex HTML color value, so I don't want transparency.

Is there an algorithm to get a tint of the System.Drawing.Color RGB value?

+5  A: 

Yep there are a lot of different ways to do this. One way would be to convert from RGB to HSB (Hue, Saturation, Brightness) and then crank the brightness down some percentage.

Charlie
I changed it to HSL, bumped the Lighting a percentage, then changed back to RGB. This works great. Here is a post on how to do this with C#, which is what I used. http://blogs.msdn.com/cjacks/archive/2006/04/12/575476.aspx
Josh Close
+1  A: 

This page does a great job of talking about different color formats, and giving visual examples how different values change the color. Oh, and it includes the math/algorithms for making the conversions ;). I think you'll want the HSL section.

Matt