- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpolygonClick.c
More file actions
Latest commit
58 lines (47 loc) · 953 Bytes
/
Copy pathpolygonClick.c
File metadata and controls
58 lines (47 loc) · 953 Bytes
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
#include<FPT.h>
intclickAndSave(doublex[100], doubley[100]){
doubleca[2];
inti=0;
intgoing=1;
while (going==1){
G_wait_click(ca);
// printf("%lf, %lf", ca[0], ca[1]);
if (ca[0] <100&&ca[1] <100){
going=0;
printf("done\n");
}else{
x[i] =ca[0];
y[i] =ca[1];
G_circle(x[i], y[i], 2);
i++;
// printf(" %d\n", i);
}
}
returni;
}
voidmyPolygon(doublex[100], doubley[100], intn){
inti=0;
while (i <= n){
if (i!=n){
G_line(x[i], y[i], x[i+1], y[i+1]);
}else {
G_line(x[i], x[i], x[0], y[0]);
}
i++;
}
}
intmain()
{
doubleax[100], ay[100], bx[100], by[100];
intanom, bnom;
G_init_graphics(600,600);
G_rgb(0,0,0);
G_clear();
G_rgb(1,1,1);
anom=clickAndSave(ax,ay);
// printf("%d\n",anom);
myPolygon(ax,ay,anom);
bnom=clickAndSave(ax, ay);
myPolygon(ax,ay,anom);
G_wait_key();
}