FROM : R. Scott Thompson
DATE : Tue Oct 12 22:41:09 2004
>> Just a note, I don't think that CGShading will let you create the
>> same kind of gradient in the sample (at least not easily).
>
> It can, you just need to use more than one gradient and composite one
> over the other.
That's why I said "(at least not easily)" :-) You might try using four
radial shadings, one centered at each of the four corners and set them
up to fade to 0 by the time you get to the opposite corner. That would
get something close, but not the same, as the barycentric shading.
You can't really use axial shadings because an axial shading can only
vary in one direction (i.e. you could get it to fade in the x
direction, but for the barycentric effect, you also want it to fade in
y and you can't do both with CGShading). What you might be able to do
is use a separate CGShading for each row of pixels... but if the goal
is to get an image with that kind of effect you'd probably see much
better performance (and simpler code) if you set up an offscreen OpenGL
context and plotted a quad with the different colors at each corner.
Another thing to watch out for is the fact that some printers may have
trouble with transparent colors in CGShadings. So long as you treat
the result of your shadings as a single image then you'll be OK. If
you try to put out a circle (for example) that has four shadings with
transparency the printer may choke on it.
Scott
--
Macintosh Software Engineering Consulting Services
Visit my resume at <http://homepage.mac.com/easco/RSTResume.html>
DATE : Tue Oct 12 22:41:09 2004
>> Just a note, I don't think that CGShading will let you create the
>> same kind of gradient in the sample (at least not easily).
>
> It can, you just need to use more than one gradient and composite one
> over the other.
That's why I said "(at least not easily)" :-) You might try using four
radial shadings, one centered at each of the four corners and set them
up to fade to 0 by the time you get to the opposite corner. That would
get something close, but not the same, as the barycentric shading.
You can't really use axial shadings because an axial shading can only
vary in one direction (i.e. you could get it to fade in the x
direction, but for the barycentric effect, you also want it to fade in
y and you can't do both with CGShading). What you might be able to do
is use a separate CGShading for each row of pixels... but if the goal
is to get an image with that kind of effect you'd probably see much
better performance (and simpler code) if you set up an offscreen OpenGL
context and plotted a quad with the different colors at each corner.
Another thing to watch out for is the fact that some printers may have
trouble with transparent colors in CGShadings. So long as you treat
the result of your shadings as a single image then you'll be OK. If
you try to put out a circle (for example) that has four shadings with
transparency the printer may choke on it.
Scott
--
Macintosh Software Engineering Consulting Services
Visit my resume at <http://homepage.mac.com/easco/RSTResume.html>
| Related mails | Author | Date |
|---|---|---|
| Peter Laurens | Aug 1, 00:40 | |
| Shawn Erickson | Aug 1, 00:53 | |
| Shawn Erickson | Aug 1, 00:59 | |
| Shawn Erickson | Aug 1, 01:09 | |
| Scott Thompson | Aug 1, 03:35 | |
| Perry Clarke | Aug 1, 05:16 | |
| Ricky Sharp | Aug 1, 16:13 | |
| Ricky Sharp | Aug 1, 18:27 | |
| John C. Randolph | Oct 12, 20:38 | |
| John C. Randolph | Oct 12, 20:48 | |
| R. Scott Thompson | Oct 12, 21:30 | |
| John C. Randolph | Oct 12, 22:29 | |
| R. Scott Thompson | Oct 12, 22:41 | |
| John C. Randolph | Oct 12, 23:07 | |
| R. Scott Thompson | Oct 12, 23:31 | |
| John C. Randolph | Oct 13, 01:38 | |
| R. Scott Thompson | Oct 13, 03:41 | |
| John C. Randolph | Oct 14, 00:26 |






Cocoa mail archive

