-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplace.js
76 lines (69 loc) · 1.48 KB
/
place.js
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
70
71
72
73
74
75
76
class Place{
constructor(x, y){
this.x = x;
this.y = y;
this.color = {
'r':255,
'g':255,
'b':255
};
this.size = 25;
}
move(x, y){
this.x = x;
this.y = y;
}
clicado(x, y){
let d = dist(x, y, this.x, this.y);
if(d < (this.size / 2)){
this.select();
return true;
}
}
intersect(ix, iy, fx, fy){
let maiorX = ix > fx ? ix : fx;
let menorX = ix > fx ? fx : ix;
let maiorY = iy > fy ? iy : fy;
let menorY = iy > fy ? fy : iy;
if(
this.x > menorX && this.x < maiorX &&
this.y > menorY && this.y < maiorY
){
if(!this.selected){
this.select();
return true;
}
} else {
this.desSelect();
return false;
}
}
selectArc(){
this.color = {
'r':255,
'g':150,
'b':150
};
this.selected = true;
}
select(){
this.color = {
'r':150,
'g':150,
'b':255
};
this.selected = true;
}
desSelect(){
this.color = {
'r':255,
'g':255,
'b':255
};
this.selected = false;
}
show(){
fill(this.color.r, this.color.g, this.color.b);
ellipse(this.x, this.y, this.size, this.size);
}
}