23
4- 23 (3). intersections are at the grid and are shared vertices: We count the ymin vertex of an edge in the parity calculation but not the ymax vertex; therefore, a ymax vertex is drawn only if it is the ymin vertex for the adjacent edge. (4). horizontal edges:  AB C D E FG H I J We do not count the vertices of a horizontal edge when calculating parity. 範例 : (assume that all vertices are at the grid) AB C D E FG H I J

24
4- 24 1. Build ET and initialize AET to be empty. 2. Set y to the smallest y coordinate that has an entry in the ET, i.e., y for the first nonempty bucket. 3. Repeat until the AET and ET are empty: 3.1 Move from ET bucket y to the AET those edges whose ymin = y, then sort the AET on x (merge sort). 3.2 Fill in desired pixel values on scan line y by using pairs of x coordinate from the AET (odd-parity rule). 3.3 Remove from the AET those edges for which y = ymax. 3.4 Increment y by 1 (set it to the next scan line). 3.5 For each nonvertical edge remaining in the AET, update x for the new y (edge coherence). Outline of the algorithm for filling polygons with solid color

25
4- 25 Seed filling Seed filling is used to fill areas defined pixels on the screen which form a bounded region. It works for a closed area of any shape. seed

28
4- 28 anchor point of bitmap: 1. put the left-top pixel of the bitmap on some vertex. 優點 : the pattern is stick to the primitive, so when the primitive is moved the pattern remains the same. 優點： easy to implement and the pattern is not dependent on the location. 缺點： need to calculate the bounding rectangle. 2. Use the left-top corner of the bounding rectangle of the primitive as the anchor point.

29
4- 29 SRGP uses this method. 3. Consider the entire screen is being tiled with the pattern and think of the primitive as consisting of an outline or filled area of transparent bits that let the pattern show through. 優點： easy to implement. 缺點： the pattern is dependent on the location. Suppose that the bitmap is an M by N array of bits. Then we can use the following code to write pixel: if (pattern[x%M,y%N]) WritePixel(x,y,value);