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>getcolor() get the current drawing color</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 getcolor()              Get the Current Drawing Color

 #include   <graphics.h>

 int far    getcolor(void);

    getcolor() returns the current drawing color.  The value returned is
    actually an index into the palette which contains the exact color
    information.  Pixels on the screen are set to this value when lines
    or figures are drawn.

    Returns:    The value of the current drawing color.

   -------------------------------- 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() setcolor()

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