You are here

getcolor function

getcolor function returns the current drawing color.

Declaration : int getcolor();

e.g. a = getcolor(); // a is an integer variable
if current drawing color is WHITE then a will be 15.
See colors in C graphics.

C programming code for getcolor

  1. #include<graphics.h>
  2. #include<conio.h>
  3.  
  4. main()
  5. {
  6.    int gd = DETECT, gm, drawing_color;
  7.    char a[100];
  8.  
  9.    initgraph(&gd,&gm,"C:\\TC\\BGI");
  10.    
  11.    drawing_color = getcolor();
  12.  
  13.    sprintf(a,"Current drawing color = %d", drawing_color);
  14.    outtextxy( 10, 10, a );
  15.  
  16.    getch();
  17.    closegraph();
  18.    return 0;
  19. }