Previous Next


                                                                                   310
CHAPTER 4                                                                                                  Graphics



domain specified by the shading dictionary’s Domain entry. The points (0, 0) and
(1, 0) in the domain correspond respectively to (x0 , y0 ) and (x1 , y1 ) on the axis.
Since all points along a line in domain space perpendicular to the line from (0, 0)
to (1, 0) have the same color, only the new value of x needs to be computed:
     ( x1 – x0 ) × ( x – x0 ) + ( y1 – y0 ) × ( y – y0 )
                                                                                                       -
x′ = ---------------------------------------------------------------------------------------------------
                            ( x1 – x0 ) 2 + ( y1 – y0 ) 2

The value of the parametric variable t is then determined from x ′ as follows:

• For 0 ≤ x ′ ≤ 1, t = t0 + (t1 − t0 ) × x ′.
• For x ′ < 0, if the first element of the Extend array is true, then t = t0 ; otherwise,
    t is undefined and the point is left unpainted.
• For x ′ > 1, if the second element of the Extend array is true, then t = t1 ; other-
    wise, t is undefined and the point is left unpainted.

The resulting value of t is passed as input to the function(s) defined by the shad-
ing dictionary’s Function entry, yielding the component values of the color with
which to paint the point (x, y).

Plate 10 shows three examples of the use of an axial shading to fill a rectangle and
display text. The area to be filled extends beyond the shading’s bounding box.
The shading is the same in all three cases, except for the values of the Background
and Extend entries in the shading dictionary. In the first example, the shading is
not extended at either end and no background color is specified; therefore, the
shading is clipped to its bounding box at both ends. The second example still has
no background color specified, but the shading is extended at both ends; the re-
sult is to fill the remaining portions of the filled area with the colors defined at the
ends of the shading. In the third example, the shading is extended at both ends
and a background color is specified; therefore, the background color is used for
the portions of the filled area beyond the ends of the shading.

Type 3 (Radial) Shadings

Type 3 (radial) shadings define a color blend that varies between two circles.
Shadings of this type are commonly used to depict three-dimensional spheres
and cones. Shading dictionaries for this type of shading contain the entries shown
in Table 4.31, as well as those common to all shading dictionaries (Table 4.28).

Previous Next