#include #include #include #include #include "ppmIO.h" /* put your include file here */ #include "line.h" #include "image.h" #define NUMLINES 200 #define TIMING 5 #define ROWS 200 #define COLS 200 /* This C program draw lines for 5 seconds (set above in TIMING constant). It executes this by repeatedly drawing NUMLINES (set above) lines which are randomly selected (both color and position). This final image is written out to the file lines.ppm. */ int main(int argc, char *argv[]) { Point start[NUMLINES], end[NUMLINES]; Color color[NUMLINES]; Image *src; Line line; long i,j; Color white; double tstart, tend; long numLines; double sum, dx, dy; struct timeb tp; color_set( &white, 1.0, 1.0, 1.0); // allocate an image ROWS by COLS src = image_create(ROWS, COLS); if(!src) { fprintf(stderr, "unable to allocate memory\n"); exit(0); } // Initialize the image to all white for(i=0;irows;i++) { for(j=0;jcols;j++) { image_setColor(src, i, j, white ); } } // Pre-calculate the line endpoints and colors so we don't have to // call the random() function inside the main drawing loop. sum = 0.0; for(i=0;i