/* Boundary Fill Algorithm */
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void boundaryFill4(int x, int y, int fill_color,int boundary_color)
{
if(getpixel(x, y) != boundary_color &&
getpixel(x, y) != fill_color)
{
putpixel(x, y, fill_color);
boundaryFill4(x + 1, y, fill_color, boundary_color);
boundaryFill4(x, y + 1, fill_color, boundary_color);
boundaryFill4(x - 1, y, fill_color, boundary_color);
boundaryFill4(x, y - 1, fill_color, boundary_color);
}
}
//driver code
int main()
{
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
int gd = DETECT, gm;
int x , y , radius;
// initgraph initializes the
// graphics system by loading a
// graphics driver from disk
printf("\n\n Enter x,y coordinates and radius of circle: ");
scanf("%d%d%d",&x,&y,&radius);
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
// circle fuction
circle(x, y, radius);
// Function calling
boundaryFill4(x, y, 6, 15);
delay(10000);
getch();
// closegraph function closes the
// graphics mode and deallocates
// all memory allocated by
// graphics system .
closegraph();
return 0;
}
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void boundaryFill4(int x, int y, int fill_color,int boundary_color)
{
if(getpixel(x, y) != boundary_color &&
getpixel(x, y) != fill_color)
{
putpixel(x, y, fill_color);
boundaryFill4(x + 1, y, fill_color, boundary_color);
boundaryFill4(x, y + 1, fill_color, boundary_color);
boundaryFill4(x - 1, y, fill_color, boundary_color);
boundaryFill4(x, y - 1, fill_color, boundary_color);
}
}
//driver code
int main()
{
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
int gd = DETECT, gm;
int x , y , radius;
// initgraph initializes the
// graphics system by loading a
// graphics driver from disk
printf("\n\n Enter x,y coordinates and radius of circle: ");
scanf("%d%d%d",&x,&y,&radius);
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
// circle fuction
circle(x, y, radius);
// Function calling
boundaryFill4(x, y, 6, 15);
delay(10000);
getch();
// closegraph function closes the
// graphics mode and deallocates
// all memory allocated by
// graphics system .
closegraph();
return 0;
}