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

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

main()
{
   int gd = DETECT, gm;
   initgraph(&gd,&gm,"C:\\TC\\BGI");

   circle(100,100,50);          /* drawn in white color */
   setcolor(RED);
   circle(200,200,50);          /* drawn in red color   */
       
   getch();
   closegraph();
   return 0;
}