-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.pde
More file actions
95 lines (79 loc) · 1.94 KB
/
Copy pathGUI.pde
File metadata and controls
95 lines (79 loc) · 1.94 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class GUI implements ControlListener
{
ControlP5 cp5;
PApplet p;
String[] animationName = {"Total Internal Reflection", "Alpha", "Screen-door Effect"};
int i,j,current;
public GUI()
{
i = 0;
current = 1;
j = 2;
}
void setCP5(ControlP5 cp5)
{
this.cp5 = cp5;
}
void setPApplet(PApplet p)
{
this.p = p;
}
void display()
{
cp5.addButton("Restart Animation")
.setPosition(200,350)
.setSize(110,20)
.setId(1)
.addListener(this);
cp5.addButton("backAnAnimation")
.setPosition(10,150)
.setSize(110,20)
.setId(3)
.setLabel(animationName[i])
.addListener(this);
cp5.addButton("forwardAnAnimation")
.setPosition(370,150)
.setSize(110,20)
.setId(4)
.setLabel(animationName[j])
.addListener(this);
}
void controlEvent(ControlEvent theEvent)
{
if(theEvent.getId() == 1)
{
print("restarting");
restartAnimation();
}
if(theEvent.getId() == 3)
{
i--;
j--;
current--;
if(i == -1)
i = 2;
else if(j == -1)
j = 2;
else if(current == -1)
current = 2;
cp5.getController("backAnAnimation").setLabel(animationName[i]);
cp5.getController("forwardAnAnimation").setLabel(animationName[j]);
setAnimationState(animationName[current]);
}
if(theEvent.getId() == 4)
{
i++;
j++;
current++;
if(i == 3)
i = 0;
else if(j == 3)
j = 0;
else if(current == 3)
current = 0;
cp5.getController("backAnAnimation").setLabel(animationName[i]);
cp5.getController("forwardAnAnimation").setLabel(animationName[j]);
setAnimationState(animationName[current]);
}
}
}