Re: UIColor vs. NSColor methods
Re: UIColor vs. NSColor methods
- Subject: Re: UIColor vs. NSColor methods
- From: Graham Cox <email@hidden>
- Date: Mon, 30 May 2011 09:41:50 +1000
On 29/05/2011, at 3:50 PM, Roland King wrote:
> You can use CGColorGetComponents on a CGColorRef to get the values of whatever colorspace the CGColorRef is in and you can create new CGColorRefs with those values.
>
> I don't see a way to convert from one colorspace to another however a quick test on one UIColor constructed with HSV values shows its contained CGColorRef to have an RGB colorspace which you could get the RGB values from. Whether you can rely on that I don't know and haven't found any documentation to back it up.
Thanks Roland, and Kyle too.
I found the same thing, so going from HSV -> RGB isn't a big problem. I'm pretty sure HSV isn't a different colourspace, it's just a convenient way to interpret RGB values. Using some simple code I looked up on the web, I wrote a method to return the RGB colour as HSV. Seems to give me the results I was looking for (since it's just for making some nice-looking gradients, it's not critical that it has super-accuracy, though I believe the code to be accurate anyway).
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden