Floodfill function in c/c++ graphics
Floodfill function in c/c++ graphics
floodfill() :
It fills a bounded region.
Syntax :
floodfill(int x,int y,int border);
Here (x,y) is the 'seed point'.
If the seed is within enclosed area, the inside will be filled.
If the seed is outside the enclosed area,the exterior will be filled.
Imp Note : The value of the border should be the value of MAX_COLOR that is 15.
Example :
#include <stdio.h>
#include <conio.h>
void main()
{
int d,m;
int midx,midy;
d=DETECT;
initgraph(&d,&m,"c:\\tc\\bgi");
midx=getmaxx()/2;
midy=getmaxy()/2;
circle(midx,midy,50);
floodfill(midx,midy,15);
getch();
closegraph();
}
Output :
Notice that the default color is white and filled pattern is plain.
If you want to change the color and filled pattern then you have to use the setfillstyle()
function. We will study it in the next topic.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment