-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoundryFill.cpp
30 lines (29 loc) · 930 Bytes
/
BoundryFill.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<conio.h>
#include<iostream>
#include<graphics.h>
using namespace std;
boundryfill(int x,int y,int color,int bordercolor)
{
if( getpixel(x,y)!= bordercolor && getpixel(x,y) != color)
{
putpixel(x,y,color);
boundryfill(x+1,y,color,bordercolor);
boundryfill(x+1,y+1,color,bordercolor);
boundryfill(x,y+1,color,bordercolor);
boundryfill(x-1,y+1,color,bordercolor);
boundryfill(x-1,y,color,bordercolor);
boundryfill(x-1,y-1,color,bordercolor);
boundryfill(x,y-1,color,bordercolor);
boundryfill(x+1,y-1,color,bordercolor);
}
}
int main()
{
int gd = DETECT;
int gm;
initgraph(&gd , &gm , "C:\\Program Files (x86)\\CodeBlocks\\MinGW\\include");
rectangle(50,50,300,250);
boundryfill(51,51,RED,WHITE);
getch();
closegraph();
}