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

  1. /*  masks.c -- illustrates _setfillmask() and         */
  2. /*             _floodfill()                           */
  3. /* Program list: masks.c                              */
  4. /* If you load graphics.qlb, no program list is needed*/
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <conio.h>
  9. #include <graph.h>
  10. unsigned char Inversemask[8];
  11. unsigned char Masks[3][8] = {
  12.             {0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00},
  13.             {0xff,0x80,0x80,0x80,0xff,0x08,0x08,0x08},
  14.             {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa}};
  15. main(argc, argv)
  16. int argc;
  17. char *argv[];
  18. {
  19.     struct videoconfig vc;
  20.     int mode = _MRES4COLOR;
  21.     short xc, yc;
  22.     short box, i;
  23.  
  24.     if (argc > 1)
  25.         mode = atoi(argv[1]);
  26.     if (_setvideomode(mode) == 0)
  27.     {
  28.         fprintf(stderr,"Can't set mode %d\n", mode);
  29.         exit(1);
  30.     }
  31.     _getvideoconfig(&vc);
  32.     xc = vc.numxpixels / 2;
  33.     yc = vc.numypixels / 2;
  34.     for (i = 0; i < 8; i++)
  35.         Inversemask[i] = ~Masks[1][i];
  36.     _setlogorg(xc, yc);
  37.     _selectpalette(0);
  38.     _setcolor(1);
  39.     _rectangle(_GBORDER, -xc + 1, -yc + 1, xc - 1, yc - 1);
  40.     _moveto(-xc + 1, -yc / 3);
  41.     _lineto(xc -1, -yc / 3);
  42.     _moveto(-xc + 1, yc / 3);
  43.     _lineto(xc -1, yc / 3);
  44.     for (box = 0; box < 3; box++)
  45.     {
  46.          _setcolor(box + 1);
  47.          _setfillmask(Masks[box]);
  48.          _floodfill(0, (box - 1) * yc / 2, 1);
  49.     }
  50.     _settextposition(5, 10);
  51.     _outtext("Press a key to continue");
  52.     getch();
  53.     _setcolor(3);
  54.     _setfillmask(Inversemask);
  55.     _floodfill (0, 0, 1);
  56.     _setcolor(2);
  57.     _setfillmask(Masks[0]);
  58.     _floodfill(0, yc / 2, 1);
  59.     _settextposition(5, 10);
  60.     _outtext("Press a key to terminate");
  61.     getch();
  62.     _setvideomode(_DEFAULTMODE);
  63. }
  64.