Floodfill function in C++

Floodfill function when executed fills an enclosed area with the colour and pattern to be inserted given  by the user. The pattern to be filled is given through setfillstyle() function.

 

This function requires three arguments. The first two are any coordinates inside the bounded region and the third one is the border colour. The general syntax of floofill() function is:

Floodfill(int x,int y,int border);

In the above syntax, x and y are any points inside the region and the border is the number representing the particular colour to be filled.

#include<conio.h>

#include<iostream.h>

#include<graphics.h>

 class draw

    {

        public:

                 void sketch()

                    {

                        setbkcolor(CYAN);

                        setcolor(YELLOW);

                       circle(300,200,120);

                       setfillstyle(HATCH_FILL,MAGENTA);

                       floodfill(300,200,YELLOW);

                    }

       };

 

    int main()

       {

           clrscr();

           int gd=DETECT,gm;

           draw c;

           clrscr();

           initgraph(&gd,&gm,"c:\\tc\\bgi");

           c.sketch();

           getch();

          closegraph();

         return 0;

       }

Output....

Floodfill function in c++

About Us

Rekha SetiaRekha Setia is a passionate blogger of Extra Computer Notes. if you have any ideas or any request me @