• Have Any Question?
  • contact@eitworld.com

Getcolor() Function

getcolor() function returns the current drawing color and default drawing color is white.

int getcolor();
  • getcolor(); returns an integer value. This integer value is a value associated with the current drawing color. Default drawing color is white and the value associated with white color is 15.
  • There are various colors that are also mentioned in graphics.h header file and the possible color values are from 0 – 15:BLACK(0), BLUE(1), GREEN(2), CYAN(3), RED(4), MAGENTA(5), BROWN(6), LIGHTGRAY(7), DARKGRAY(8), LIGHTBLUE(9), LIGHTGREEN(10), LIGHTCYAN(11), LIGHTRED(12), LIGHTMAGENTA(13), YELLOW(14), WHITE(15).
  • You can also set drawing color of your choice by setcolor() function.
  • For better understanding go through the program:





void main()


int gd=DETECT, gm,color;

char a[50];

initgraph(&gd,&gm,” “);


sprintf(a,”The value of the current drawing color is %d”,color);





Above program will get the current drawing color with the help of getcolor() function. This returns the value associated with the current drawing and stores it in the integer variable color. The default drawing color is white and value associated with white color is 15 so it stores the 15 in integer variable color. Then the program will display a message as given in the output.



Real Time Web Analytics