HOT C PROGRAMS BLOGSPOT

HOT C PROGRAMS BLOGSPOT

Click On Related Results For More Information

Thursday 11 October 2012

Graphics Boundary Fill C Program

/* .......Works on Win XP */
/*Works on XP but there is something wrong in it, needs some debug in program, Keep circle radius less than 30, Carefully give the old colour. */


#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void boundary_fill(int x,int y,int f,int b)
{ int current;
current=getpixel(x,y);
delay(2);
if(current!=f && current!=b)
{putpixel(x,y,f);
  boundary_fill(x+1,y,f,b);
  boundary_fill(x,y+1,f,b);
  boundary_fill(x-1,y,f,b);
  boundary_fill(x,y-1,f,b);;
}
}
void main()
{int gd=DETECT,gm,x,y,r,xc,yc,f,b;
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,&b);
initgraph(&gd,&gm,"C:\\TC\\BGI");   /*Sometimes it may be "c:\\tc\\bgi" , It depends machine to mac..*/
setcolor(4);
circle(xc,yc,r);
boundary_fill(x,y,f,b);
getch();
closegraph();
}

No comments:

Post a Comment