Objective-C RGB to HSB
Posted
by Johannes Jensen
on Stack Overflow
See other posts from Stack Overflow
or by Johannes Jensen
Published on 2010-04-07T08:43:32Z
Indexed on
2010/04/07
9:03 UTC
Read the original article
Hit count: 581
Let's say I've got the colour FF0000, which is red. Finding a darker colour is easy, I just type maybe CC instead of the FF, but let's say I've got the colour AE83FC, which is a complicated colour, how the heck would I find a lighter or darker version of it automatically?
I figured the easy way to do this is to convert my RGB to HSB [Hue, Saturation, Brightness]
How would I do that in Objective-C?
Let's say I've got a RGB which is: 1.0, 0.0, 0.0. That's red.
CGFloat r = 1.0;
CGFloat g = 0.0;
CGfloat b = 0.0;
How would I convert that to HSB and then transform the colors and make it go back to RGB to I can use CGContextRGBSetFillColor?
Are there any HSB functions?
Please help. :)
© Stack Overflow or respective owner