Docsity

Polygon, Polygon Types - Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Polygon, Polygon Types - Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Computer Graphics

Filled Area Primitives II

Lecture 09

Filled Area Primitives

 There are two basic approaches to area filling on raster systems.

 scan-line polygon filling

 Boundary-fill and Flood-fill

Polygon types

 Does a straight line connecting ANY two points that are inside the polygon intersect any edges of the polygon?

Convex polygons

 If the answer is no then polygon is convex

Complex polygons

 Complex polygons are basically concave polygons that may have self-intersecting edges

Unfilled polygons

 When an unfilled polygon is rendered, only the points on the perimeter of the polygon are drawn.

Parity

 Parity is a concept used to determine which pixels lie within a polygon, i.e. which pixels should be filled for a given polygon.

ODD number of edges

 Point is inside the polygon filled area

Even number of edges II

 Point lies outside the circle

Polygon Filling Algorithm

 When filling a polygon, you will most likely just have a set of vertices, indicating the x and y Cartesian coordinates of each vertex of the polygon. The following steps should be taken to turn your set of vertices into a filled polygon.

 For each edge, the following information needs to be kept in a table:

  1. The minimum y value of the two vertices
  2. The maximum y value of the two vertices
  3. The x value associated with the minimum y value
  4. The slope of the edge

Cont…

 The slope of the edge can be calculated from the formula for a line y = mx + b

N 10 16 28 0

**- - - -

      • -**

1 16 20 10 1.

0 10 16 10 0

Index Y-min Y-max X-val 1/m

Table: All edges

  1. Initialize the Global edge Table

 Edges with the same minimum y values are sorted on minimum x values as follows:

  1. First edge with non zero slope.
  2. If the slope of an edge is zero, do not add it.
  3. For every other edge, start at index 0 and look for an appropriate position for the edge, in ascending order of minimum y-values