Header file:
graphics.h
Synopsis:
void setfillstyle (int pattern, int color);
pattern - fill pattern
color - fill color
Description:
setfillstyle() sets the current fill pattern and fill color.
setfillstyle 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);
/* sets the current fill style */
setfillstyle(i % 12, i);
/* draws circle at the center of the screen */
circle(midx, midy, circleRadius);
/* fill the bounded region with current fill color */
floodfill(midx, midy, i);
getch();
}
/* clean up */
getch();
closegraph();
return 0;
}
Output: (setfillstyle built-in function in c graphics.h)
No comments:
Post a Comment