-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnection.pde
More file actions
66 lines (58 loc) · 1.82 KB
/
Connection.pde
File metadata and controls
66 lines (58 loc) · 1.82 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
public class Connection{
PlugKey k1, k2;
float gap;
int r, g, b;
public Connection(PlugKey k1, PlugKey k2){
this.k1 = k1;
this.k2 = k2;
gap = connectionGap;
r = int(random(50,255));
g = int(random(50,255));
b = int(random(50,255));
k1.setSelectedColors(r,g,b);
k2.setSelectedColors(r,g,b);
}
public PlugKey getK1(){
return k1;
}
public PlugKey getK2(){
return k2;
}
public void show(){
stroke(r, g, b);
if (k1.getRow() != k2.getRow()){
line1();
return;
}
if (k1.getRow() == 0){
line2();
return;
}
if (k1.getRow() == 1){
line3();
return;
}
}
public void line1(){
if (k1.getRow() == 0){
line(k1.getX(), k1.getY(), k1.getX(), k1.getY() + gap);
line(k1.getX(), k1.getY() + gap, k2.getX(), k1.getY() + gap);
line(k2.getX(), k1.getY() + gap, k2.getX(), k2.getY());
}
if (k1.getRow() == 1){
line(k1.getX(), k1.getY(), k1.getX(), k1.getY() - gap);
line(k1.getX(), k1.getY() - gap, k2.getX(), k1.getY() - gap);
line(k2.getX(), k1.getY() - gap, k2.getX(), k2.getY());
}
}
public void line2(){
line(k1.getX(), k1.getY(), k1.getX(), k1.getY() - gap);
line(k1.getX(), k1.getY() - gap, k2.getX(), k1.getY() - gap);
line(k2.getX(), k1.getY() - gap, k2.getX(), k2.getY());
}
public void line3(){
line(k1.getX(), k1.getY(), k1.getX(), k1.getY() + gap);
line(k1.getX(), k1.getY() + gap, k2.getX(), k1.getY() + gap);
line(k2.getX(), k1.getY() + gap, k2.getX(), k2.getY());
}
}