|
|
Subclassing NSColor
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Boy, this is poorly-documented. The documentation tells you to override colorSpaceName and set, but it doesn't give any information on how to make your color actually do anything. For instance, say I wanted to replicate the functionality of NSPatternColor--how would I go about this? What sort of thing would I need to put in my set implementation to make it go, "Hey, I need to tile this image?"
Anybody care to help?
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
I can't offer much advice for NSColor subclassing, but if you're just wanting to use tiled patterns as colors, try +[NSColor colorWithPatternImage:].
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Originally posted by Rickster:
I can't offer much advice for NSColor subclassing, but if you're just wanting to use tiled patterns as colors, try +[NSColor colorWithPatternImage:].
Yeah, I pretty much have that. I was just using it as an example. Thanks, though.
Basically what I wanted to do is have it so that the background of a box can be either a color or a gradient. The most logical way seemed to be to subclass NSColor so that I could just switch between subclasses. But I suppose I could just use separate drawing routines for the two modes.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
Most of the built-in NSColor subclasses implement -set to call various NSGraphicsContext and CoreGraphics API to set up state on the current graphics context, I believe. It might be possible to, say, use GoreGraphics' new API for gradients to implement gradient colors this way. It's certainly possible to do things like implementing a new color space (like LAB or a Pantone list) via subclassing NSColor -- just perform your own translation to RGB and set that on the context -- in fact, that's probably what the class is designed around.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|