HOT C PROGRAMS BLOGSPOT

HOT C PROGRAMS BLOGSPOT

Click On Related Results For More Information

Thursday 11 October 2012

Graphics Flood Fill C Program

 /* .......Works on Win XP */


#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void flood_fill(int x,int y,int f,int o)
{ int current;
current=getpixel(x,y);
delay(2);
if(current==o)
{putpixel(x,y,f);
flood_fill(x,y+1,f,o);
flood_fill(x,y-1,f,o);
flood_fill(x+1,y,f,o);
flood_fill(x-1,y,f,o);;
}
}
void main()
{int gd=DETECT,gm,x,y,r,xc,yc,f,o;
clrscr();
printf("\nEnter the seed point");
scanf("%d%d",&x,&y);
printf("\nEnter the center & radius of the circle");
scanf("%d%d%d",&xc,&yc,&r);
printf("\nEnter the fill and old color");
scanf("%d%d",&f,&o);
initgraph(&gd,&gm,"C:\\TC\\BGI");   /*Sometimes it may be "c:\\tc\\bgi" , It depends machine to mac..*/
setcolor(4);
circle(xc,yc,r);
flood_fill(x,y,f,o);
getch();
closegraph();
}


 /* Seed Pt and Center must be same,  Circle radius should be  less or equal to 30 otherwise machine may hang,  old colour be 0 always */










1 comment: