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

[pastacode lang=”c” manual=”%23include%3Cgraphics.h%3E%0A%23include%3Cconio.h%3E%0A%20%0Amain()%0A%7B%0A%20%20%20int%20gd%20%3D%20DETECT%2C%20gm%3B%0A%20%20%20initgraph(%26gd%2C%26gm%2C%22C%3A%5C%5CTC%5C%5CBGI%22)%3B%0A%20%0A%20%20%20circle(100%2C100%2C50)%3B%20%20%20%20%20%20%20%20%20%20%2F*%20drawn%20in%20white%20color%20*%2F%20%0A%20%20%20setcolor(RED)%3B%0A%20%20%20circle(200%2C200%2C50)%3B%20%20%20%20%20%20%20%20%20%20%2F*%20drawn%20in%20red%20color%20%20%20*%2F%0A%20%0A%20%20%20getch()%3B%0A%20%20%20closegraph()%3B%0A%20%20%20return%200%3B%0A%7D” message=”” highlight=”” provider=”manual”/]

Categorized in: