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

  1. /*  eggs.c -- draws colorful eggs                                      */
  2. /*  This program illustrates use of the video configuration            */
  3. /*  structure, the _ellipse() function, the effect of over-            */
  4. /*  lapping solid figures, and a the use of logical coordinates.       */
  5. /*  If you load graphics.qlb, no program list is needed.               */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <graph.h>
  10. #include <conio.h>
  11. #define ESC '\033'
  12.  
  13. main(argc, argv)
  14. int argc;
  15. char *argv[];
  16. {
  17.     struct videoconfig vc;
  18.     int mode = _MRES4COLOR;
  19.     short xcent[3], ycent[3]; /* egg centers */
  20.     short xsize, ysize;       /* egg limits  */
  21.     int egg;
  22.  
  23.     if (argc > 1)
  24.         mode = atoi(argv[1]);
  25.     if (_setvideomode(mode) == 0)
  26.     {
  27.         printf("Can't open mode %d\n", mode);
  28.         exit(1);
  29.     }
  30.     _getvideoconfig(&vc);
  31.     xsize = 0.3 * vc.numxpixels;
  32.     ysize = 0.3 * vc.numypixels;
  33.     xcent[0] = 0.3 * vc.numxpixels;
  34.     xcent[1] = 0.5 * vc.numxpixels;
  35.     xcent[2] = 0.7 * vc.numxpixels;
  36.     ycent[0] = ycent[2] = 0.4 * vc.numypixels;
  37.     ycent[1] = 0.6 * vc.numypixels;
  38.  
  39.     _selectpalette(0);
  40.     _setbkcolor(_MAGENTA);
  41.     for (egg = 0; egg < 3; egg++)
  42.     {
  43.         _setlogorg(xcent[egg], ycent[egg]);
  44.         _setcolor(egg + 1);
  45.         _ellipse(_GFILLINTERIOR, -xsize, -ysize, xsize, ysize);
  46.     }
  47.     _settextposition(24, 0);
  48.     _settextcolor(1);
  49.     _outtext("Strike any key to terminate.");
  50.     getch();
  51.     _setvideomode(_DEFAULTMODE);
  52. }