#include <graphics.h>
#include <stdio.h>
#include <conio.h>
void flood_fill(int,int,int,int);
int main()
{
int xc,yc,r,fc,ic;
int gd=DETECT,gm;
initgraph(&gd,&gm," ");
printf("\n\n Enter xc:");
scanf("%d",&xc);
printf("\n\n Enter yc:");
scanf("%d",&yc);
printf("\n\n Enter r:");
scanf("%d",&r);
setcolor(8);
circle(xc,yc,r);
printf("\n\n Enter fill color:");
scanf("%d",&fc);
printf("\n\n Enter interior Color");
scanf("%d",&ic);
//setcolor(2);
//circle(xc,yc,r);
flood_fill(xc,yc,fc,ic);
getch();
closegraph();
return 0;
}
void flood_fill(int x1,int y1,int fc1,int ic1)
{
int c=getpixel(x1,y1);
printf("\n\n %d",c);
//int bc=0;
if(c==ic1)
{
putpixel(x1,y1,fc1);
flfill(x1+1,y1,fc1,ic1);
flfill(x1,y1+1,fc1,ic1);
flfill(x1-1,y1,fc1,ic1);
flfill(x1,y1-1,fc1,ic1);
// getch();
}
}
This comment has been removed by the author.
ReplyDeleteNice program, to see more simplified program click here
ReplyDelete