home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Graphics / graphics-16000.iso / msdos / animutil / fastgfx / fg110c / 06-10.c < prev    next >
Text File  |  1992-01-30  |  753b  |  38 lines

  1. #include <fastgraf.h>
  2.  
  3. void main(void);
  4.  
  5. #define RECTANGLES 200
  6. #define SWAP(a,b,temp) { temp = a; a = b; b = temp; }
  7.  
  8. void main()
  9. {
  10.    int i;
  11.    int minx, maxx, miny, maxy;
  12.    int old_mode;
  13.    int temp;
  14.    int xres, yres;
  15.  
  16.    old_mode = fg_getmode();
  17.    fg_setmode(fg_automode());
  18.  
  19.    xres = fg_getmaxx() + 1;
  20.    yres = fg_getmaxy() + 1;
  21.  
  22.    for (i = 0; i < RECTANGLES; i++) {
  23.       minx = rand() % xres;
  24.       maxx = rand() % xres;
  25.       miny = rand() % yres;
  26.       maxy = rand() % yres;
  27.       if (minx > maxx)
  28.          SWAP(minx,maxx,temp);
  29.       if (miny > maxy)
  30.          SWAP(miny,maxy,temp);
  31.       fg_setcolor(rand()%16);
  32.       fg_rect(minx,maxx,miny,maxy);
  33.       }
  34.  
  35.    fg_setmode(old_mode);
  36.    fg_reset();
  37. }
  38.