-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboundary_fill.c
More file actions
69 lines (52 loc) · 1.53 KB
/
boundary_fill.c
File metadata and controls
69 lines (52 loc) · 1.53 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
61
62
63
64
65
66
67
68
69
////////////////////////////////BOUNDARY FILL////////////////////////////////
//Run in TurboC
//Compile- Ctrl+F9
//libraries
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void BoundaryFill(int, int, int, int);
int main()
{
/*
xc- x center coordiante of circle
yc- y center coordiante of circle
r- radius of circle
*/
//initialization
int xc, yc, r, gdriver, gmode;
//declaration
gdriver=DETECT;
//Graph Initialization
//initgraph() in <graphics.h>
//Path can vary according to the system
initgraph(&gdriver, &gmode, "C:\\TurboC3\\bgi");
printf("Enter the coordinates of the center of the circle: ");
scanf("%d %d",&xc, &yc);
printf("Enter the radius of the circle: ");
scanf("%d", &r);
setcolor(BLUE);
//circle(int xCenter, int yCenter, int Radius)
circle(xc, yc, r);
//to delaly the execution
//delay(milli-seconds)
delay(80);
BoundaryFill(xc, yc, RED, BLUE);
//charater input
//getch() in <conio.h>
getch();
closegraph();
return 0;
}
void BoundaryFill(int x, int y, int fill, int bound)
{
int c=getpixel(x, y);
if(c! = bound && c! = fill)
{
putpixel(x, y, fill);
BoundaryFill(x, y+1, fill, bound);
BoundaryFill(x, y-1, fill, bound);
BoundaryFill(x-1, y, fill, bound);
BoundaryFill(x+1, y, fill, bound);
}
}