Whenever I execute this code below, the whole screen fills up with a grid pattern in red. I just want to fill the circular region in red.
#include<graphics.h>
#include<conio.h>
void main(){
int gm, gd=DETECT;
initgraph(&gd,&gm,"c:\\turboC3\\bgi");
circle(100,100,50);
setfillstyle(HATCH_FILL,RED);
floodfill(100,100,RED);
getch();
closegraph();
}
Output:
In the line floodfill(100,100,RED)
, the third parameter has to be the color of the border. As by default, your circle's border color is WHITE
, so change your code to:
#include<graphics.h>
#include<conio.h>
void main(){
int gm, gd=DETECT;
initgraph(&gd,&gm,"c:\\turboC3\\bgi");
circle(100,100,50);
setfillstyle(HATCH_FILL,RED);
//Change RED to WHITE.
floodfill(100,100,WHITE);
getch();
closegraph();
}
Thanks to you, I learnt a new thing today. :)