'C: Using floodfill to fill a circle
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:

Solution 1:[1]
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. :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | shauryachats |
