-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboundaryfill.cpp
More file actions
60 lines (54 loc) · 1.36 KB
/
boundaryfill.cpp
File metadata and controls
60 lines (54 loc) · 1.36 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void fourpoints(int x, int y, int fill, int stroke)
{
if((getpixel(x, y) !=stroke ) && (getpixel(x, y) != fill))
{
delay(1);
putpixel(x, y, fill);
fourpoints(x+1, y, fill, stroke);
fourpoints(x, y + 1, fill, stroke);
fourpoints(x - 1, y, fill, stroke);
fourpoints(x, y - 1, fill, stroke);
}
}
void eightpoints(int x,int y,int fill, int stroke )
{
if((getpixel(x, y) !=fill) && (getpixel(x, y) != stroke))
{
putpixel(x, y, fill);
eightpoints(x + 1, y, fill, stroke);
eightpoints(x, y + 1, fill, stroke);
eightpoints(x - 1, y, fill, stroke);
eightpoints(x, y - 1, fill, stroke);
eightpoints(x - 1, y - 1, fill, stroke);
eightpoints(x - 1, y + 1, fill, stroke);
eightpoints(x + 1, y - 1, fill, stroke);
eightpoints(x + 1, y + 1, fill, stroke);
}
}
int main()
{
int gd=DETECT,gm;
initgraph(&gd, &gm,"");
int choice;
printf("Enter your choice:\n");
printf("\n1. 4 points connected");
printf("\n2. 8 points connected\n");
scanf("%d",&choice);
rectangle(50,50,200,200);
switch(choice)
{
case 1:
fourpoints(55, 55, 15, 4);
break;
case 2:
eightpoints(70, 70, 7, 15);
break;
default:
printf("Invalid Choice");
}
getch();
return 0;
}