-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtransition.js
87 lines (79 loc) · 1.77 KB
/
transition.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
77
78
79
80
81
82
83
84
85
86
87
class Transition{
constructor(x, y){
this.x = x;
this.y = y;
this.color = {
'r':255,
'g':255,
'b':255
};
this.width = 10;
this.height = 26;
}
move(x, y){
this.x = x;
this.y = y;
}
rotate(){
let aux = this.width;
this.width = this.height;
this.height = aux;
}
clicado(x, y){
if(
x > (this.x - this.width/2) && x < ((this.width/2) + this.x) &&
y > (this.y - this.height/2) && y < ((this.height/2) + this.y)
){
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(){
rectMode(CENTER);
fill(this.color.r, this.color.g, this.color.b);
rect(this.x, this.y, this.width, this.height);
rectMode(CORNER);
}
}