home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / graphics / cgapal.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-25  |  1.0 KB  |  39 lines

  1. /* CGAPAL.C illustrates CGA palettes using:
  2.  *      _selectpalette
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <conio.h>
  8. #include <graph.h>
  9.  
  10. long bkcolor[8] = { _BLACK,  _BLUE,     _GREEN,  _CYAN,
  11.                     _RED,    _MAGENTA,  _BROWN,  _WHITE };
  12. char *bkname [] = { "BLACK", "BLUE",    "GREEN", "CYAN",
  13.                     "RED",   "MAGENTA", "BROWN", "WHITE" };
  14. main()
  15. {
  16.     int i, j, k;
  17.  
  18.     if ( !_setvideomode( _MRES4COLOR ) )
  19.         exit( 1 );
  20.     for( i = 0; i < 4; i++ )
  21.     {
  22.         _selectpalette( i );
  23.         for( k = 0; k < 8; k++ )
  24.         {
  25.             _setbkcolor( bkcolor[k] );
  26.             for( j = 0; j < 4; j++ )
  27.             {
  28.                 _settextposition( 1, 1 );
  29.                 printf( "Background color: %8s\n", bkname[k] );
  30.                 printf( "Palette: %d\nColor: %d\n", i, j );
  31.                 _setcolor( j );
  32.                 _rectangle( _GFILLINTERIOR, 160, 100, 320, 200 );
  33.                 getch();
  34.             }
  35.         }
  36.     }
  37.     exit( !_setvideomode( _DEFAULTMODE ) );
  38. }
  39.