Re: CGShading line, triangle?
Re: CGShading line, triangle?
- Subject: Re: CGShading line, triangle?
- From: Alastair Houghton <email@hidden>
- Date: Tue, 9 Dec 2003 18:29:12 +0000
On 9 Dec 2003, at 17:49, Henry McGilton wrote:
>
On Tuesday, December 9, 2003, at 01:45 AM, Alastair Houghton wrote:
>
>
> I think you can probably do what you want with a triangle using
>
> multiple linear CGShadings (hint: you can fade the colour at the
>
> corner
>
> down to transparent towards the other end of the triangle). My
>
> intuition suggests that two CGShadings should be sufficient, although
>
> using three might make it easier.
>
>
I suspect that what Alex wants here is a Gouraud shader.
Oh, absolutely. That's why I suggested OpenGL at the end of my post.
Equally, your triangle subdivision code is a good way of implementing
it if what you want is a real Gouraud shader.
>
Looks like CGShading is pretty limited --- axial and radial only?!?
Yes, but, using more than one shading with alpha should enable you to
obtain a Gouraud-like result. I don't think you can get it exactly
right, although you can probably get a reasonable approximation if you
sit down and go through the maths. (To give an example of the general
idea, imagine three shadings that only vary alpha along the
perpendicular from each vertex, from 1.0 at the vertex down to 0.0 at
the other end of the perpendicular; obviously this won't give the same
results as a real Gouraud algorithm, but it might look OK depending on
the application).
The primary benefit in choosing this method is that CGShadings turn
into PDF gradient fills, which take up a lot less space (and processing
time) than any other colour interpolation.
>
> As far as doing a gradient fill of a thick line, I don't know any way
>
> of getting the line's outline as a path, which is what you'd need in
>
> order to do this. I think you'd have to convert it to a path
>
> manually;
>
> it doesn't look stunningly tricky to do the necessary geometry.
>
>
At first glance, you should be able to use the Axial shader with a clip
>
path that is constructed using NSBezierPath. What in the Axial
>
shader is
>
not doing what you want?
I don't think it's the shading here that is the problem; I think he was
asking specifically how to obtain geometry for the outline of a thick
polyline. AFAIK, that's something you have to do for yourself.
Obviously, once you have that, then an axial shader with the clip path
set to the path defining the outline will work nicely.
Kind regards,
Alastair.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.