Saturday, April 6, 2013

floodfill function

Declaration :- void floodfill(int x, int y, int border);
floodfill function is used to fill an enclosed area. Current fill pattern and fill color is used to fill the area.(x, y) is any point on the screen if (x,y) lies inside the area then inside will be filled otherwise outside will be filled,border specifies the color of boundary of area. To change fill pattern and fill color use setfillstyle. Code given below draws a circle and then fills it.

C programming code

#include<graphics.h>
#include<conio.h>
 
main()
{
   int gd = DETECT, gm;
 
   initgraph(&gd, &gm, "C:\\TC\\BGI");
 
   setcolor(RED);
   circle(100,100,50);
   floodfill(100,100,RED);
 
   getch();
   closegraph();
   return 0;
}
In the above program a circle is drawn in RED color. Point (100,100) lies inside the circle as it is the center of circle, third argument to floodfill is RED which is color of boundary of circle. So the output of above program will be a circle filled with WHITE color as it is the default fill color.
floodfill program.
Output of program:
filled circle

No comments:

Post a Comment