Previous Next
242
CHAPTER 4 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 % Set DeviceGray color space
gray SC % Set gray level
gray G % 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.
Example 4.3 shows alternative ways to select the DeviceRGB color space and a
specific color within that space for stroking operations.
Example 4.3
/DeviceRGB CS % Set DeviceRGB color space
red green blue SC % Set color
red green blue RG % Set both in one operation
Previous Next