Exercise 1.1

In order to set the current color to green, pink, violet, or orange, we will need to use the setrgbcolor word with values of r, g, and b that correspond to the color.

For example, one specific shade of green is rgb(71, 178, 35) in rgb color space using 8 bit coordinates. When normalized, the setrgbcolor command to set the current color to that shade of green is

write "example.ps"
71 255 div 178 255 div 35 255 div setrgbcolor newpath 144 144 moveto 144 0 rlineto 0 144 rlineto -144 0 rlineto 0 -144 rlineto closepath fill showpage

Then, we can build this using Ghostscript and get a rendered picture.

build example.png example.ps
gs -o example.png -sDEVICE=pngalpha example.ps

Below is the image that was generated, with our specific color of green displayed.

picture example.png