Computer Graphics: Lecture 05-Polygon Filling
Computer Graphics: Lecture 05-Polygon Filling
• Scan-Line Algorithm
• Boundary fill algorithm
Polygons
A polygon is a many-sided planar figure composed of vertices and
edges. A polygon is bounded (finite area) and closed (includes
boundary).
E1
(x1,y1) (x2,y2)
E3 E2
(x3,y3)
Polygons
Scan-Line Algorithm
6
For scan-line number 7 the sorted list
of x-coordinates is (1,3,7,9)
4
e f
X-max
Case-1:If scan line passes through vertex Case-2:If scan line passes through vertex
and both the edges that are connected to and both the edges that are connected to
the vertex are on the same side of the the vertex are on the different side of the
scan line, then the vertex should scan line, then the vertex should
considered as 2 intersection points. considered as a single intersection point.
Scan-Line Algorithm
Y-max a c
b
h i g
u z
v y
e f
X-max
Start Position
x + 1, y R
x - 1, y L
x, y + 1 T
x, y – 1 B
3
2
1
1
2 3
4
2
1 4
1
2
2
1
1
2
5
5 1
1
1
1
Some region remains unfilled
8-connected (Example)
Start Position
4 1 5
5
2 3
4
3
2
1
6
4 1
6
2 3
4
3
2
1
7 8
8
4 1
7
2 3
4
3
2
1
12
11 9 12
11
7 10
10
9
4 1
7
2 3
4
3
2
1
11 9
11
7 10
10
9
4 1
7
2 3
4
3
2
1
9
7 10
10
9
4 1
7
2 3
4
3
2
1
9
7
9
4 1
7
2 3
4
3
2
1
7
4 1
7
2 3
4
3
2
1
4 1
2 3
4
3
2
1
1
2 3
3
2
1
1
2
2
1
1