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

  1. /*  rect.c -- illustrates logical coordinates,         */
  2. /*            the _rectangle() and _setlinestyle()     */
  3. /*            functions                                */
  4. /* If you load graphics.qlb, no program list is needed */
  5.  
  6. #include <stdio.h>
  7. #include <graph.h>
  8. #include <conio.h>
  9. #define STYLES 5
  10. short Linestyles[STYLES] = {0xFFFF, 0x8888, 0x7777,
  11.                             0x00FF, 0x8787};
  12.  
  13. main(argc, argv)
  14. int argc;
  15. char *argv[];
  16. {
  17.     struct videoconfig vc;
  18.     int mode = _MRES4COLOR;
  19.     int xcent, ycent;
  20.     int xsize, ysize;
  21.     int i;
  22.  
  23.     if (argc > 1)
  24.         mode = atoi(argv[1]);
  25.     if (_setvideomode(mode) == 0)
  26.     {
  27.         printf("Can't open that mode.\n");
  28.         exit(1);
  29.     }
  30.     _getvideoconfig(&vc);
  31.     xcent = vc.numxpixels / 2 - 1;
  32.     ycent = vc.numypixels / 2 - 1;
  33.     _setlogorg(xcent, ycent);
  34.     xsize = 0.9 * xcent;
  35.     ysize = 0.9 * ycent;
  36.     _selectpalette(1);
  37.     _setcolor(3);
  38.     _rectangle(_GBORDER, -xsize, -ysize, xsize, ysize);
  39.     xsize *= 0.9;
  40.     ysize *= 0.9;
  41.     _setcolor(1);
  42.     _rectangle(_GFILLINTERIOR, -xsize, -ysize, xsize, ysize);
  43.     for (i = 0; i < 16; i++)
  44.     {
  45.         _setcolor(((i % 2) == 0) ? 2 : 3);
  46.         _setlinestyle(Linestyles[ i % 5 ]);
  47.         xsize *= 0.9;
  48.         ysize *= 0.9;
  49.         _rectangle(_GBORDER, -xsize, -ysize, xsize, ysize);
  50.     }
  51.     getch();      /* Type a key to terminate. */
  52.     _setvideomode(_DEFAULTMODE);
  53. }
  54.