Similarly the mathematical top boundary of the rectangle is at y 3 so we set

Similarly the mathematical top boundary of the

This preview shows page 127 - 128 out of 662 pages.

Similarly, the mathematical top boundary of the rectangle is at y = 3, so we set the top pixel row for the displayed rectangle at y = 2. These compensations for finite pixel width along object boundaries can be applied to other polygons and to curved figures so that the raster display main- tains the input object specifications. A circle of radius 5 and center position (10, lo), for instance, would be displayed as in Fig. 3 3 3 by the midpoint circle algo- rithm using screen grid coordinate positions. But the plotted circle has a diameter of 11. To plot the cmle with the defined diameter of 10, we can modify the circle algorithm to shorten each pixel scan line and each pixel column, as in Fig. 3-34. One way to do this is to generate points clockwise along the circular arc in the third quadrant, starting at screen coordinates (10, 5). For each generated point, the other seven circle symmetry points are generated by decreasing the 1' coordi- nate values by 1 along scan lines and decreasing the y coordinate values by 1 along pixel culumns. Similar methods are applied in ellipse algorithms to main- tain the specified proportions in the display of an ellipse. 3-1 1 FILLED-AREA PRIMITIVES I\ standard output primitive in general graphics packages is a solid-color or pat- terned polygon area. Other kinds of area primitives are sometimes available, but polygons are easier to process since they have linear boundaries There are two basic approaches to area filling on raster systems. One way to fill an area is to determine the overlap mtervals for scan lines that cross the area. Another method for area filling is to start from a given interior position and paint outward from this point until we encounter the specified boundary conditions. The scan-line approach is typically used in general graphics packages to fill poly- gons, circles, ellipses, and other simple curves. All methods starting from an inte- rior point are useful with more complex boundaries and in interactive painting systems. In the following sections, we consider n~etliods for solid fill of specified areas. Other fill options are discussed in Chapter 4. St an-Lint. Polygon Fill Algorithm Figure 3-35 illustrates the scan-line procedure for soha tilling of polygon areas. For each scan line crossing a polygon, the area-fill algorithm locates the intersec- tion points of the scan line with the polygon edges. These intersection points are then sorted from left to right, and the corresponding frame-buffer positions be- tween each intersection pair are set to the specified fill color. In the example of Fig. 3-35, the four pixel intersection positions with the polygon boundaries define two stretches of interior pixels from x = 10 to x = 14 and from x = 18 to x = 24. Some scan-line intersections at polygon vertices require special handling.
Image of page 127
Image of page 128

You've reached the end of your free preview.

Want to read all 662 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture