Professional Documents
Culture Documents
Unit-I
Introduction: Computer Graphics, Computer Graphics Applications.
Video Display Devices: Refresh Cathode Ray Tube, Raster Scan displays, Random Scan Displays,
Architecture of Raster and Random Scan Monitors, Color CRT-monitors, Color Generating
Techniques (Shadow Mask, Beam Penetration), Direct View Storage Tube, Flat Panel Display,
Graphics monitors and Workstations.
Two dimensional Graphics Primitives: Points and Lines, Point plotting Techniques: Coordinate
system, Increment method, Line drawing algorithm: DDA, Bresenham’s line drawing, Bresenham‘s
circle drawing algorithm: Using polar coordinates, Midpoint circle drawing algorithms Filled area
algorithm: Scan line, Polygon filling algorithms, Boundary filled algorithms.
2
Contents
3
The Scan-Line Polygon Fill Algorithm
A
(Procedure) C
1. Locate the x-intersection points of the scan
Scan Line Y
line with the polygon edges. B
For scan-line Y=8, the x-intersection
points are x=2, x=6, x=12 and x=15
2. Sort these intersection points from left to E
D
right.
(2, 8), (6, 8), (12, 8) and (15,8) (2, 8) (6, 8) (12, 8) (15, 8)
Fig. 3.38 Intersection points along scan lines that intersect polygon vertices. Scan line y generates an odd number of intersections, but scan 5
line y‘ generals an even number of intersections that can be paired to identify correctly the interior pixel spans
The Scan-Line Polygon Fill Algorithm
Dealing with vertices
F
D
For scan line y the vertices
which belong to two edges are C G
listed in Table-02 below. E
K
Table-3.11 (b) List of vertices belongs to
B
two edges for scan line y and y’
H J L
Vertex Edges
A GA and AB A
H GH and HI
J IJ and JK
L KL and LM
I
G M
(x’’, H)
A A
A A
Fig. 3.41 Adjusting end point y values for a polygon, as we process edges in order around the polygon perimeter. The
edge currently being processed is indicated as a solid line. In (a), the y coordinate of the upper endpoint of the current
edge is decreased by 1. In (b), the y coordinate of the upper endpoint of the next edge is decreased by 1.
C C 8
The Scan-Line Polygon Fill Algorithm
A
Determining Edge Intersections
m = (yk+1 – yk) / (xk+1 – xk)
yk+1 = yk + 1 As per DDA Line Algorithm
when |m| > 1 C
xk+1 = xk + 1/m
B
Fig. 3.42 Two successive scan lines intersecting polygon boundary
9
The Scan-Line Polygon Fill Algorithm
• Each entry in the table for a particular scan line contains the maximum yy value for that edge, the x-
intercept value (at the lower vertex) for the edge, and the inverse slope of the edge.
Fig. 3.43 A polygon and its sorted edge table, with edge DC shortened by one unit in the y 10
direction.
The Scan-Line Polygon Fill Algorithm
(Example) Polygon = {A, B, C, D, E, F, G}, Polygon = {(2, 7), (4, 12), (8,15), (16, 9), (11, 5), (8, 7), (5, 5)}
EDGE TABLE
C
# EDGE 1/m ymin x ymax
(a) (b)
Fig. 3.45 Adjusting end point y values for a polygon, as we process edges in order around the polygon perimeter. The
edge currently being processed is indicated as a solid line. In (a), the y coordinate of the upper endpoint of the current
edge is decreased by 1 and respective vertices calculation. In (b), the y coordinate of the upper endpoint of the next edge 12
is decreased by 1 and respective vertices calculation.
The Scan-Line Polygon Fill Algorithm
Table – 3.13 Adjusting end point y values for each polygon edge AB
A(2, 7) B(4, 12) C(8, 15) YP < YC < yN Not Local Split B
Extremum
B(4, 12) C(8, 15) D(16, 9) YP < YC > yN Local Maximum None
C(8, 15) D(16, 9) E(11, 5) YP > YC > yN Not Local Split D
Extremum
A(2, 7) B(4, 12) C(8, 15) 7 < 12 < 15 Not Local Split B
Extremum
B(4, 12) C(8, 15) D(16, 9) YP < YC > yN Local Maximum None
C(8, 15) D(16, 9) E(11, 5) YP > YC > yN Not Local Split D
Extremum
Vertex B should be split into two vertices B' (xB', 11) and B(4, 12) If yP < yC < yN
m =( 7 – 12)/( 2 – 4) = 5/2 Then yC is decreased by one. The new edges become
(xp,yP) (x’C, yC – 1) and (xC,yC) (xN, yN )
xB’ = 2 + (2/5)( 12 – 1 – 7) = 18/5 = 3.6 4
m = (yP - yC)/(xP – xC)
The vertex B is split to B' (4, 11) and B(4, 12)
X’C = xP + (1/m)(yC – 1 - yP) 14
The Scan-Line Polygon Fill Algorithm
(Example)
Table – 3.15 Adjusting end point y values for each polygon edge BC
A(2, 7) B(4, 12) C(8, 15) YP < YC < yN Not Local Split B
Extremum
B(4, 12) C(8, 15) D(16, 9) YP < YC > yN Local Maximum None
C(8, 15) D(16, 9) E(11, 5) 15 > 9 > 5 Not Local Split D
Extremum
ACTIVATION TABLE
Scan Line - Y 5 6 7 8 9 10 11 12 13 14 15
Activated Edge # 3, 4, 5, 6 0 2 1
16
The Scan-Line Polygon Fill Algorithm
(Example)
20
THANK YOU
21