Eric Weeks - personal pages - graphics techniques

Color Postscript tutorial

(follow above link to Graphics Techniques to see earlier postscript tutorials)
[home] [research]
[software] [pics]
[misc] [about me]

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:

CommandColor
1 0 0 setrgbcolorred
0 1 0 setrgbcolorgreen
0 0 1 setrgbcolordark blue
0 1 1 setrgbcolorlight blue
1 0 1 setrgbcolormagenta
1 1 0 setrgbcoloryellow
1 1 1 setrgbcolorwhite
0 0 0 setrgbcolorblack
1.0 0.7 0.0 setrgbcolororange
0.7 0.3 1.0 setrgbcolorpurple
0.7 0.3 0.0 setrgbcolorbrown
0.0 0.5 0.0 setrgbcolordark 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.

Click here to get this program.

To compile, "gcc -o palette palette2.c". This program won't compile using "cc" because it doesn't like how I printed out large chunks of text; this is easy to fix yourself if you don't have gcc. You'll need to edit the functions "printheader()" and "printtrailer()" to give each line of text its own printf() statement.

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.


Questions?

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.

Links...


Current address:
Eric R. Weeks
weeks(circle a)physics.emory.edu
Department of Physics
Emory University
Atlanta, GA 30322-2430