home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap15 / scape.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-07  |  1.5 KB  |  56 lines

  1. /* scape.c -- uses nondefault EGA colors              */
  2. /* If you load graphics.qlb, no program list is needed.*/
  3.  
  4. #include <stdio.h>
  5. #include <graph.h>
  6. #include "egacolor.h"
  7. #include <stdlib.h>
  8. #include <conio.h>
  9. #define SKY (b | B | g)
  10. #define OCEAN b
  11. #define SAND (R | g | b)
  12. #define SUN (R | G | r | g)
  13.  
  14. main(argc, argv)
  15. int argc;
  16. char *argv[];
  17. {
  18.     struct videoconfig vc;
  19.     int mode = _ERESCOLOR;
  20.     short xmax, ymax, sunx, suny, sunsizex, sunsizey;
  21.     float ar;
  22.  
  23.  
  24.     if (argc > 1)
  25.         mode = atoi(argv[1]);
  26.     if (_setvideomode(mode) == 0)
  27.         {
  28.         fprintf(stderr,"mode %d not supported\n", mode);
  29.         exit(1);
  30.         }
  31.     _getvideoconfig(&vc);
  32.     xmax = vc.numxpixels - 1;
  33.     ymax = vc.numypixels - 1;
  34.     sunx = 0.7 * xmax;
  35.     suny = 0.2 * ymax;
  36.     ar = (float)(10 * vc.numypixels) / (6.5 * vc.numxpixels);
  37.     sunsizex = xmax / 30;
  38.     sunsizey = ar * sunsizex;
  39.     _remappalette(1, SKY);
  40.     _remappalette(2, OCEAN);
  41.     _remappalette(3, SAND);
  42.     _remappalette(4, SUN);
  43.     _setcolor(1);
  44.     _rectangle(_GFILLINTERIOR, 0, 0, xmax, 2 * ymax / 5);
  45.     _setcolor(4);
  46.     _ellipse(_GFILLINTERIOR, sunx - sunsizex, suny -
  47.              sunsizey, sunx + sunsizex, suny + sunsizey);
  48.     _setcolor(2);
  49.     _rectangle(_GFILLINTERIOR, 0, 2 * ymax / 5, xmax,
  50.                2 * ymax / 3);
  51.     _setcolor(3);
  52.     _rectangle(_GFILLINTERIOR, 0, 2 * ymax / 3, xmax, ymax);
  53.     getch();
  54.     _setvideomode(_DEFAULTMODE);
  55. }
  56.