You are here

setcolor function in c

Declaration: void setcolor(int color);

In Turbo Graphics each color is assigned a number. Total 16 colors are available. Strictly speaking number of available colors depends on current graphics mode and driver.For Example :- BLACK is assigned 0, RED is assigned 4 etc. setcolor function is used to change the current drawing color.e.g. setcolor(RED) or setcolor(4) changes the current drawing color to RED. Remember that default drawing color is WHITE.

C programming code for setcolor

  1. #include<graphics.h>
  2. #include<conio.h>
  3.  
  4. main()
  5. {
  6.    int gd = DETECT, gm;
  7.    initgraph(&gd,&gm,"C:\\TC\\BGI");
  8.  
  9.    circle(100,100,50);          /* drawn in white color */
  10.    setcolor(RED);
  11.    circle(200,200,50);          /* drawn in red color   */
  12.        
  13.    getch();
  14.    closegraph();
  15.    return 0;
  16. }