[comp.lang.postscript] multiple color fill?

sotbill@vax2.concordia.ca (06/21/91)

I asked this question before without success (not even an answer).
Is it possible to do gradiant filling in postscript? Can I make
a small subroutine (function) that will take points of a triangle
and color at each of them and draw the triangle with interpolated
colors inside the triangle without using "colorimage"? Do I have
to use "colorimage"? Speed is not my main concern here.

A while back, I read in PCMag review of vector based graphics
translator that Postscript could do gradient fills. I have looked
in the reference manual, but I could not find anything about it.
The only reference I found so far was in the "green book", chapter
8, where they show a square filled black to white using the
"image" operator.

That type of thing is done on Silicon Graphics workstations without
a second thought.

Any kind of help (references or other) on this will be welcome, thanx

Richard Lefebvre
sotbill@vax2.concordia.ca

uad1077@dircon.co.uk (Ian Kemmish) (06/22/91)

sotbill@vax2.concordia.ca writes:

>I asked this question before without success (not even an answer).
>Is it possible to do gradiant filling in postscript? Can I make
>a small subroutine (function) that will take points of a triangle
>and color at each of them and draw the triangle with interpolated
>colors inside the triangle without using "colorimage"? Do I have
>to use "colorimage"? Speed is not my main concern here.

>A while back, I read in PCMag review of vector based graphics
>translator that Postscript could do gradient fills. I have looked
>in the reference manual, but I could not find anything about it.
>The only reference I found so far was in the "green book", chapter
>8, where they show a square filled black to white using the
>"image" operator.

>That type of thing is done on Silicon Graphics workstations without
>a second thought.

>Any kind of help (references or other) on this will be welcome, thanx

>Richard Lefebvre
>sotbill@vax2.concordia.ca

Well, if enough of us holler loudly enough about it, maybe gradient
fills could be included as yet another special colour space in
PostScript Level 3?  It's certainly a very useful facility to
have.

Another possibility that I have been playing with, but which is
nowhere near commercial yet, is to have `shaders' like Renderman.

If you set the colour space to `shader' and the underlying space to
`DeviceRGB', then you might say something like
{ y 1 y sub 0 } setcolor
to define a shader which went [almost] smoothly from red to green
as the y co-ordinate varied....

Someday!

-- 
Ian D. Kemmish                    Tel. +44 767 601 361
18 Durham Close                   uad1077@dircon.UUCP
Biggleswade                       ukc!dircon!uad1077
Beds SG18 8HZ United Kingdom    uad1077@dircon.co.uk

davis@3d.enet.dec.com (Peter Davis) (06/25/91)

In article <538@daily-planet.concordia.ca>, sotbill@vax2.concordia.ca writes...
>Is it possible to do gradiant filling in postscript?

Yes, it's possible, but it's not built into the language.  At least, not in
Level 1.

The way to do this is to write a procedure which sets the outline of the area to
be filled as your clip path, and then draws individual bars, circles, or
whatever in gradually varying colors.  In other words, you have to do the
graduation yourself.  You can use various tricks to figure out how wide you want
the bands of color to be, such as figuring out the size of a pixel on the output
device.

In Level 2 PostScript, there's actually a color space for "pattern fills."  I
haven't looked at this closely enough yet to figure out if it will do what you
want.  I think you'll still have to write the looping procedure to draw bands of
different colors, but you'll be able to define it as a fill pattern, so
referring to it will be simpler.

-pd