Sunday, 23 March 2014

Boundary Fill Algorithm Using C

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

void boundryFill(int, int, int, int);
int midx=319, midy=239;

void main()
{
int gdriver=DETECT, gmode, x,y,r;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
cleardevice();
printf("Enter the Center of circle (X,Y) : ");
scanf("%d %d",&x,&y);
printf("Enter the Radius of circle R : ");
scanf("%d",&r);
circle(midx+x,midy-y,r);
getch();
boundryFill(midx+x,midy-y,13,15);
getch();
closegraph();
}
void boundryFill(int x, int y, int fill, int boundry)
{
if((getpixel(x,y)!= fill) && (getpixel(x,y) != boundry))
{
putpixel(x,y,fill);
delay(5);
boundryFill(x+1,y,fill,boundry);
boundryFill(x-1,y,fill,boundry);
boundryFill(x,y+1,fill,boundry);
boundryFill(x,y-1,fill,boundry);
}
}

No comments:

Post a Comment