Header file:
graphics.h
Synopsis:
void setcolor (int color);
color - current drawing color
Description:
setcolor() sets the current drawing color.
setcolor function in c graphics
#include <conio.h>
#include <graphics.h>
#include <dos.h>
int main() {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int i, err, midx, midy;
int circleRadius = 150;
/* initialize graphics system */
initgraph(&graphicDriver, &graphicMode, "C:/TURBOC3/BGI");
err = graphresult();
if (err != grOk) {
/* error occurred */
printf("Graphic Error: %s\n",
grapherrormsg(err));
return 0;
}
/* mid position x and y-axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;
for (i = 0; i < 15; i++) {
/* sets the current line style */
setlinestyle(SOLID_LINE, 1, THICK_WIDTH);
/* sets the current drawing color */
setcolor(i);
/* draws circle at the center of the screen */
circle(midx, midy, circleRadius);
getch();
}
/* clean up */
getch();
closegraph();
return 0;
}
Output: (setcolor built-in function in c graphics.h)
No comments:
Post a Comment