Created
November 16, 2010 06:30
-
-
Save madebyjeffrey/701522 to your computer and use it in GitHub Desktop.
CGColor property for NSColor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Version 3: Simplified, but still can have an exception thrown in the case of a non-floating point colour space. | |
@implementation NSColor (CGColor) | |
@dynamic CGColor; | |
- (CGColorRef) CGColor | |
{ | |
CGColorSpaceRef colorspace = [[self colorSpace] CGColorSpace]; | |
const NSInteger nComponents = [self numberOfComponents]; | |
CGFloat components[nComponents]; | |
[self getComponents: components]; | |
CGColorRef c = CGColorCreate(colorspace, components); | |
return (CGColorRef)[(id)c autorelease]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment