CHAPTER 4
242
Graphics
DeviceGray Color Space
Black, white, and intermediate shades of gray are special cases of full color. A
grayscale value is represented by a single number in the range 0.0 to 1.0, where
0.0 corresponds to black, 1.0 to white, and intermediate values to different gray
levels. Example 4.2 shows alternative ways to select the
DeviceGray
color space
and a specific gray level within that space for stroking operations.
Example 4.2
/DeviceGray CS
gray
SC
gray
G
% Set DeviceGray color space
% Set gray level
% Set both in one operation
The
CS
and
SC
operators select the current stroking color space and current
stroking color separately;
G
sets them in combination. (The
cs
,
sc
, and
g
opera-
tors perform the same functions for nonstroking operations.) Setting either cur-
rent color space to
DeviceGray
initializes the corresponding current color to 0.0.
DeviceRGB Color Space
Colors in the
DeviceRGB
color space are specified according to the additive
RGB
(red-green-blue) color model, in which color values are defined by three compo-
nents representing the intensities of the additive primary colorants red, green,
and blue. Each component is specified by a number in the range 0.0 to 1.0, where
0.0 denotes the complete absence of a primary component and 1.0 denotes maxi-
mum intensity. If all three components have equal intensity, the perceived result
theoretically is a pure gray on the scale from black to white. If the intensities are
not all equal, the result is some color other than a pure gray.
DeviceRGB
color space and a
specific color within that space for stroking operations.
Example 4.3
/DeviceRGB CS
red green blue
SC
red green blue
RG
% Set DeviceRGB color space
% Set color
% Set both in one operation