Home > Computer Graphics > >program to fill polygon using FLOODFILL algorithm.

>program to fill polygon using FLOODFILL algorithm.

>/*program to fill polygon using FLOODFILL algorithm*/

#include stdio.h
#include conio.h
#include graphics.h
#include dos.h

void flood(int,int,int,int);

void main()
{
int gd,gm=DETECT;
clrscr();
detectgraph(&gd,&gm);
initgraph(&gd,&gm,”c:\\tc\\bgi”);
rectangle(50,50,100,100);
flood(55,55,12,0);
getch();
}

void flood(int x,int y, int fill_col, int old_col)
{
if(getpixel(x,y)==old_col)
{
delay(10);
putpixel(x,y,fill_col);
flood(x+1,y,fill_col,old_col);
flood(x-1,y,fill_col,old_col);
flood(x,y+1,fill_col,old_col);
flood(x,y-1,fill_col,old_col);
}
}

About these ads
  1. puspendu
    May 5, 2014 at 5:14 pm

    pg really works

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: