Eric Weeks
- personal pages - graphics
techniquesColor Postscript tutorial(follow above link to Graphics Techniques to see earlier postscript tutorials) |
weeks@physics.emory.edu |
Color PostScript is trivial. For black & white pictures, you specify shades of gray with the command "setgray". "0 setgray" is black and "1 setgray" is white. For color PostScript, you can specify the color with the command "setrgbcolor". You give that command 3 numbers, the red, green, and blue levels. Thus:
Command | Color |
---|---|
1 0 0 setrgbcolor | red |
0 1 0 setrgbcolor | green |
0 0 1 setrgbcolor | dark blue |
0 1 1 setrgbcolor | light blue |
1 0 1 setrgbcolor | magenta |
1 1 0 setrgbcolor | yellow |
1 1 1 setrgbcolor | white |
0 0 0 setrgbcolor | black |
1.0 0.7 0.0 setrgbcolor | orange |
0.7 0.3 1.0 setrgbcolor | purple |
0.7 0.3 0.0 setrgbcolor | brown |
0.0 0.5 0.0 setrgbcolor | dark green |
This table I got from looking at what the output is on one particular color printer; this is not from a book, so take it with a grain of salt. Or, preferably, generate your own color table with the following program. (Or just download the color table in Postscript form.)
This is a program I wrote which prints out squares of color along with the RGB values the program used to generate each square. Very useful for picking colors.
This program makes a page that looks something like this:
Click here to download the postscript file that produces this
page
-- you don't necessarily need the program, just this
page.
What if you don't have a color printer? No problem; you don't have to actually print PostScript pictures for them to be useful. You can easily convert PostScript pictures to other formats and put them on your web page; click here for more information.
Yes, I know the color chart is slightly redundant; what I do is show gradations in color between nine different "nice" colors (red, green, dk blue, lt blue, yellow, magenta, white, black, and medium gray). With nine target colors there are 9*8/2=36 different pairs of colors to show the gradations between. I show 5 colors between each pair of "nice" colors, for a total of 216 boxes; the "nice" colors are each repeated four times.