Graphics Programs Reference
In-Depth Information
• The
DeviceGray
color space has one additive component, which varies from 0.0
(Black) to 1.0 (White).
• The
DeviceRGB
color space has three additive components for Red, Green, and
Blue. They each range from 0.0 (e.g., no Red) to 1.0 (e.g., full Red).
• The
DeviceCMYK
color space has four subtractive components for Cyan, Magenta,
Yellow, and Key (Black). They each range from 0.0 (no pigment) to 1.0 (full pig-
ment).
To change the stroke color space, we use the
CS
operator. To change the fill color space,
use
cs
instead. The
SC
operator (with a number of operands equal to the number of
components in the current color space) can then be used to set the stroke color, or
sc
to set the fill color. For example:
/DeviceRGB CS
Set stroke color space
0.0 0.5 0.9 SC
Set color to RGB (0.0, 0.5, 0.9)
There are shortcut operators for the device color spaces, which set the current stroke
or fill color space and the current stroke or fill color in one operation. These are sum-
marized in
Table 5-7
.
Table 5-7. Simple color and color space operators
Operator
Operands
Function
G
1
Change stroke color space to
/DeviceGray
and set color
g
1
Change fill color space to
/DeviceGray
and set color
RG
3 (R, G, B)
Change stroke color space to
/DeviceRGB
and set color
rg
3 (R, G, B)
Change fill color space to
/DeviceRGB
and set color
K
4 (C, M, Y, K)
Change stroke color space to
/DeviceCMYK
and set color
k
4 (C, M, Y, K)
Change fill color space to
/DeviceCMYK
and set color
When a content stream begins, the default color space is
/DeviceGray
and the default
color value is 0 (fully black), so we can use the
g
operator straight away:
200 250 100 100 re f
0.25 g
300 250 100 100 re f
0.5 g
400 250 100 100 re f
0.75 g
500 250 100 100 re f
The result is shown in
Figure 5-7
.