Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_setcolor() set color</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _setcolor()             Set color

 #include   <graph.h>

 short far _setcolor( color );
  short color;      Desired color value

    _setcolor() sets the current foreground color to the specified value,
    which is then used by any of the subsequent drawing functions:
    _arc(), _ellipse(), _floodfill(), _lineto(), _pie(), _rectangle(),
    and _setpixel().

    The color values available depend on the installed display hardware
    and selected video mode. The available colors can be determined at
    runtime by examining the struct videoconfig member numcolors,
    returned by getvideoconfig(). The default color is the highest
    numbered color in the current palette.

       Returns:     There is no useful return value.

   Portability:     MS-DOS only, true MDPA, CGA, EGA, MCGA, or VGA video
                    compatibles

 -------------------------------- Example ---------------------------------

    This program draws a dotted line through a pie-shape, reversing the
    line where it intersects the pie.

           #include <conio.h>
           #include <graph.h>

           main()
           {
              struct xycoord xy;
              short color;
              int i;

              _setvideomode( _MRES4COLOR );
              color = _getcolor();
              _pie( _GFILLINTERIOR, 90, 60, 250, 160, 250, 22, 10, 160 );
              xy = _getviewcoord( 0, 0 );
              _moveto ( xy.xcoord, xy.ycoord );

              for ( i = 0; i < 72; i++ )
                 {
                 xy = _getcurrentposition( );
                 _moveto( xy.xcoord + 4, xy.ycoord + 2 );

                 /* test and reverse foreground and background colors */
                 if( _getpixel( xy.xcoord,  xy.ycoord) ==
                     (short) _getbkcolor() )
                    _setcolor( color );
                 else
                    _setcolor( (short) _getbkcolor() );
                 _setpixel( xy.xcoord,  xy.ycoord);
                 }

              while ( !kbhit() );
              _setvideomode( _DEFAULTMODE );
           }


See Also: _getcolor() _setbkcolor() _getbkcolor() _setpixel()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson