Re: A way to use multiple colours with one NSBezierPath?
Re: A way to use multiple colours with one NSBezierPath?
- Subject: Re: A way to use multiple colours with one NSBezierPath?
- From: Graham Cox <email@hidden>
- Date: Sat, 4 Oct 2008 16:59:08 +1000
On 4 Oct 2008, at 1:54 pm, Michael Robinson wrote:
I would like to draw one path, which is used as a border.
I naively assumed I could change the colour of the path as it is
constructed, but it seems this is not the case.
If I change the colour (using [[NSColor blackColor] set]; for
example), this changes the colour for the entire path.
Basically what I would like to know is:
Is it possible to use multiple colours in one line, as in the
following:
Bottom + BR + BL corners = black
Right = Orange
Top + TR + TL corners = black
Left = Orange
Yes, I know this would be hideous, it is just an example.
I was attempting this by using [[NSColor aColor] set]; after each
path element is drawn, but it is causing the whole path to take the
value of the last set colour.
I would also like to say that I really appreciate the incredible
amount of quality suggestions and advice I have received from this
list, you're all wonderfully talented and kind.
Without your help I would have bashed my computer into little pieces
long ago.
NSBezierPath does not store information about its rendering appearance
(except stroke width and a couple of other stroking parameters), it
only stores the geometry. To achieve paths in different colours, you
need to set the colour and draw each path.
To achieve what you describe above, you need to create separate paths
for each differently coloured part of the object. You could also
devise a class that "has a" path + a colour to make it a bit more
convenient, but there's nothing like that built in.
hth,
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