Spring 2000

Department of Computer Science

Lab Assignment 2

Write a program in C, C++, or Java that implements the scan-line polygon-fill algorithm discussed in class. Your program must read from standard input the specifications of at most 100 polygons. Each polygon will be specified by the number of vertices in the polygon, followed by the x and y integer coordinates of each vertex. Your program can assume there will be no more that 10 vertices per polygon.

For example, here is the input for one polygon:

   3  90 50  110 120  130 50
and here is the input for four polygons:
   3  90 50  110 120  130 50
   3  290 50  310 120  330 50
   4  210 110  190 160  210 180 230 160
   4  10 170  210 350  410 170  210 280

The graphical result of the second example should look like this:

You are encouraged to use lab2-skeleton.c as a starting point. After adding a lot of print statements to my solution to this assignment, I got this debugging output when run with the second example input above.