The header file graphics.h contains setcolor() function which is used to set the current drawing color to the new color.
Syntax :
void setcolor(int color);
Explanation : In Graphics, each color is assigned a number. Total number of colors available are 16. Number of available colors depends on current graphics mode and driver. For example, setcolor(RED) or setcolor(4) changes the current drawing color to RED. Remember that default drawing color is WHITE. The Colors table is given below.
COLOR INT VALUES
-------------------------------
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
Below is the implementation of setcolor() function.
#include <graphics.h>
#include <stdio.h>
int main()
{
int gd = DETECT, gm, color;
initgraph(&gd, &gm, "" );
circle(100, 100, 50);
setcolor(GREEN);
circle(200, 200, 50);
getch();
closegraph();
return 0;
}
|
Output :
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
23 Jan, 2018
Like Article
Save Article