Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>setcolor() set the current drawing color</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 setcolor()              Set the Current Drawing Color

 #include   <graphics.h>

 void far   setcolor(color);
 int        color;

    setcolor() sets the current drawing color to 'color', which
    represents an index into the palette.  The range of values 'color'
    can have is determined by the size of the palette. getmaxcolor() will
    return the highest possible color value, which is (size-1).
    Therefore, the range of possible color values is 0 to (size-1).

    Returns:    Nothing.

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

    The following statements draw three rectangles, the first in the
    original drawing color. The color value is stored, the drawing color
    is set to 'red' and the second rectangle is drawn. The drawing color
    is restored to its original value and the third rectangle is drawn.

           #include <graphics.h>
           #include <conio.h>

           int gdriver = DETECT;
           int gmode;

           main()
           {
               int whcolor;

               initgraph(&gdriver,&gmode,"");
               whcolor = getcolor();
               rectangle(100,100,200,150);
               setcolor(4);
               rectangle(300,100,400,150);
               setcolor(whcolor);
               rectangle(100,250,200,300);
               getch();
               closegraph();
           }


See Also: getpalette() getmaxcolor() getcolor()

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