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

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void main(void);
  6.  
  7. #define RECTANGLES 200
  8. #define SWAP(a,b,temp) { temp = a; a = b; b = temp; }
  9.  
  10. void main()
  11. {
  12.    int i;
  13.    int minx, maxx, miny, maxy;
  14.    int old_mode;
  15.    int temp;
  16.    int xres, yres;
  17.  
  18.    if (fg_egacheck() == 0) {
  19.       printf("This program requires EGA or VGA.\n");
  20.       exit(1);
  21.       }
  22.  
  23.    old_mode = fg_getmode();
  24.    fg_setmode(fg_automode());
  25.    fg_setfunc(3);
  26.  
  27.    xres = fg_getmaxx() + 1;
  28.    yres = fg_getmaxy() + 1;
  29.  
  30.    for (i = 0; i < RECTANGLES; i++) {
  31.       minx = rand() % xres;
  32.       maxx = rand() % xres;
  33.       miny = rand() % yres;
  34.       maxy = rand() % yres;
  35.       if (minx > maxx)
  36.          SWAP(minx,maxx,temp);
  37.       if (miny > maxy)
  38.          SWAP(miny,maxy,temp);
  39.       fg_setcolor(rand()%16);
  40.       fg_rect(minx,maxx,miny,maxy);
  41.       }
  42.  
  43.    fg_setmode(old_mode);
  44.    fg_reset();
  45. }
  46.