0% found this document useful (0 votes)
23 views16 pages

Cgma PDF

Uploaded by

Sheheryar Waseem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
23 views16 pages

Cgma PDF

Uploaded by

Sheheryar Waseem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 16
/ If both edges are on the right, the pixel‘is not drawn and is counted just once for parity purposes. This is due to the fact that right edges are not drawn in the sean-line polygon fill implementation. A Simple Example Just to reiterate the algorithm, the following simple example of scan-line polygon filling will be outlined. Initially, each vertice of the polygon is given in the form of (x,y) and is in an ordered array as» such: ordered_vertices | — (10, 10) 1} (40, 16) 2) (16,20) 3] . (28,10) 4] (28, 16) 5] (22,10) Unfilled, the polygon would look like this to the human eye: (16, 20) 0 (10, 10) (22,10) (28, 10) Scanned with CamScanner * will now walk through the steps of the algorithm to fill in the polygon- 1 Initializing AMl of the Edges: / J smmine the minimum y value, maxim i 5 g n for We want to dete wm y value, x value, and U/io cach edge and keep them inthe all edges table. We determine these values forth list edge fs follows, | Yomin: Since the first edge consists ofthe first and second vertex in the array we use | ¥ Values of those vertices to choose the lesser y valu. In this case it is 10 Y-max: In the first edge, the greatest y value is 16. X-val: \ Since the x value associated with the vertex with the highest y val 0. 10 i the x value for this edge. im: ‘Using the given formula, we get (10-10)/(16-10) for 1m. The edge value results are in the form of Y-min, Y-max, X-val, Slope for each edye array pointed to in the all_edges table. As a result of calculating all edge values, 1 following in the all_edges table Scanned with CamScanner all_edges 16 | 1070 20 | 10 [is 20 [28 |-12 16 [28] 0 16 [2] 4 10 | 10 | ink : uy, rex ut xO J . Initializing the Global Edge Table: ‘We want to place all the edges in the global edge table in increasing y and x values, as long as slope is not equal to zero. For the first edge, the slope is not zero so itis placed in the global edge table at index=0. global ° 0| @++ 10 | 16 | 10 wrt. KOMI J TAX w/t For the second edge, the slope is not zero and the minimum y value is greater than that at zero, s0 it is placed in the global-edge table at index=1. Scanned with CamScanner 16 | 10 | 0 20 | 10 | 15 ca ae e258 BE 6 8 - s equal ti For the third edge, the slope is not zero and the minimum y val den! Zero and the x value is greater than that at index 0, so the index is ince the third edge has a lesser minimum y value than the edge at ind:

You might also like