Created
January 20, 2017 17:16
-
-
Save synsh/f3694df613a91ce9ab3ff74ff077a20d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<graphics.h> | |
void boundary_fill(int x,int y,int boundary_color,int fill_color); | |
int main() | |
{ | |
int gd,gm,x,y,x1,x2,y1,y2; | |
detectgraph(&gd,&gm); | |
initgraph(&gd,&gm,"C://TurboC3//BGI"); | |
printf("Enter top-left point of rectangle: "); | |
scanf("%d%d",&x1,&y1); | |
printf("Enter bottom-right point of rectangle: "); | |
scanf("%d%d",&x2,&y2); | |
cleardevice(); | |
setcolor(WHITE); | |
rectangle(x1,y1,x2,y2); | |
boundary_fill(x1+1,y1+1,15,4); | |
getch(); | |
closegraph(); | |
return 0; | |
} | |
void boundary_fill(int x,int y,int boundary_color,int fill_color) | |
{ | |
int current; | |
current=getpixel(x,y); | |
if(current!=boundary_color && current!=fill_color) | |
{ | |
putpixel(x,y,fill_color); | |
delay(10); | |
boundary_fill(x+1,y,boundary_color,fill_color); | |
boundary_fill(x,y+1,boundary_color,fill_color); | |
boundary_fill(x-1,y,boundary_color,fill_color); | |
boundary_fill(x,y-1,boundary_color,fill_color); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment