You are on page 1of 1

Pattern Fill We select fill patterns with

setInteriorStyleIndex (pi)

where pattern index parameter pi specifies a table position. For example, the following set of statements would fill the area defined in the f illArea command with the second pattern type stored in the pattern table:
setInteriorStyle (pattern); setInteriorStyleIndex (2); fillArea (n, points);

Separate tables are set up for hatch patterns. If we had selected hatch fill for the interior style in this program segment, then the value assigned to parameter pi is an index to the stored patterns in the hatch table. For fill style pattern, table entries can be created on individual output devices with

setPatternRepresentation (ws, pi, nx, ny, cp)

Parameter pi sets the pattern index number for workstation code ws, and cp is a twodimensional array of color codes with nx columns and ny rows. The following program segment illustrates how this function could be used to set the first entry in the pattern table for workstation 1.
cp[1,1] := 4;
cp [ 1 , 2 ] : = 0; cp [ 2 , 2 ] : = 4;

cp [ 2 , 1 ] : = 0;

setPatternRepresentation (1, 1, 2, 2, cp);

Table 4-3 shows the first two entries for this color table. Color array cp in this example specifies a pattern that produces alternate red and black diagonal pixel lines on an eightcolor system. When a color array cp is to be applied to fill a region, we need to specify the size of the area that is to be covered by each element of the array. We do this by setting the rectangular coordinate extents of the pattern:
setPatternSize (dx, dy)

where parameters dx and dy give the coordinate width and height of the array napping. An example of the coordinate size associated with a pattern array is ~ven in Fig. 4-20. If the values for dx and dy in this figure are given in screen co)rdinates, then each element of the color array would be applied to a 2 by 2 ,creen grid containing four pixels. A reference position for starting apattern fill is assigned with the statement

setPatternReferencePoint (position)

'arameter posi tion is a pointer to coordinates (xp, yp) that fix the lower left orner of the rectangular pattern. From this starting position, the pattern is then ~plicated in the x and y directions until the defined area is covered by nonover

You might also like