-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.pde
289 lines (230 loc) · 6.55 KB
/
GUI.pde
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
////////////////////////////
// Conrol Window ///////
////////////////////////////
ControlFrame addControlFrame(String theName, int theWidth, int theHeight) {
Frame f = new Frame(theName);
ControlFrame p = new ControlFrame(this, theWidth, theHeight);
f.add(p);
p.init();
f.setTitle(theName);
f.setSize(p.w, p.h);
f.setLocation(100, 100);
f.setResizable(false);
f.setVisible(true);
return p;
}
// the ControlFrame class extends PApplet, so we
// are creating a new processing applet inside a
// new frame with a controlP5 object loaded
public class ControlFrame extends PApplet {
int w, h;
public void setup() {
size(w, h);
frameRate(25);
fill(255);
background(0);
List l = java.util.Arrays.asList(photoSets);
cp5 = new ControlP5(this);
int y=0;
y+=10;
cp5.addToggle("PLAY")
.plugTo(parent, "play")
.setPosition(20, y).setSize( (w-60)/2, 20);
cp5.addBang("reload")
.setLabel("REload").setPosition((w-60)/2 + 40, y).setSize(( w-60)/2, 20);
y+=40;
cp5.addBang("backImage")
.setLabel("back")
.setPosition(20, y)
.setSize(w/4, 20);
cp5.addBang("nextImage")
.setLabel("next image")
.setPosition(40+w/4, y)
.setSize(3*w/4-60 , 20);
y+=40;
cp5.addToggle("PauseFlip")
.plugTo(parent, "pauseFlip")
.setLabel("No Flip")
.setPosition(20, y).setSize(40, 20);
cp5.addToggle("randomMode")
.plugTo(parent, "randomMode")
.setLabel("rnd mode")
.setPosition(80, y).setSize(40, 20);
cp5.addToggle("randomMatrix")
.plugTo(parent, "randomMatrix")
.setLabel("rnd matrix")
.setPosition(140, y).setSize(40, 20);
y+=45;
cp5.addSlider("Sort Speed")
.plugTo(parent, "sortSpeed")
.setPosition(20,y)
.setSize(w/2,15)
.setRange(1,5)
.setValue(1)
.setNumberOfTickMarks(5)
;
y+=35;
cp5.addToggle("Wrap")
.plugTo(parent, "wrap")
.setState(true)
.setPosition(w/2, y).setSize(w/3, 20);
cp5.addToggle("Sort Flip")
.plugTo(parent, "logic")
.setPosition(20, y).setSize(w/3, 20)
.setMode(ControlP5.SWITCH);
y+=50;
text("Mode", 20, y);
y+=10;
cp5.addRadioButton("changeMode")
//.plugTo(parent, "mode")
.setPosition(20, y).setSize(30, 20)
.setColorLabel(color(255))
.setItemsPerRow(3)
.setSpacingColumn(20)
.addItem("A", 0).addItem("B", 1).addItem("C", 2)
.addItem("D", 3).addItem("E", 4).addItem("F", 5)
.activate(2)
;
y+=70;
text("Sort Matrix", 20, y);
y-=15;
cp5.addBang("clearMatrix")
.setCaptionLabel("CLR")
.setPosition(w-60, y).setSize(10, 10);
y+=25;
cp5.addCheckBox("sortMatrix")
.setLabel("mode")
.setPosition(20, y).setSize(40, 20)
.setColorLabel(color(255))
.setItemsPerRow(3)
.setSpacingColumn(10)
.addItem("1", 0).addItem("2", 0).addItem("3", 0)
.addItem("4", 0).addItem("5", 0).addItem("6", 0)
.addItem("7", 0).addItem("8", 0).addItem("9", 0)
;
y+=80;
cp5.addRange("range")
.setBroadcast(false)
.setPosition(20, y)
.setSize(w-60, 20)
.setHandleSize(10)
.setRange(0, 255)
.setRangeValues(20, 150)
.setBroadcast(true)
;
y+=30;
cp5.addSlider("FRate")
.plugTo(parent, "frameRate")
.setRange(0.5, 40)
.setValue(25)
.setPosition(20, y)
.setSize(w-60, 20)
;
y+=30;
cp5.addSlider("flipTime")
.plugTo(parent, "flipSpeed")
.setRange(2, 200)
.setValue(30)
.setPosition(20, y)
.setSize(w/2, 20)
;
y+=50;
Group g1 = cp5.addGroup("g1")
.setLabel("overlay")
.setPosition(20, y)
.setSize(w-40, 30)
.setBackgroundColor(color(100))
;
cp5.addSlider("hue")
.plugTo(parent, "overlayHue")
.setRange(0, 255)
.setValue(0)
.setPosition(0, 10)
.setSize(60, 10)
.setGroup(g1)
;
cp5.addSlider("alpha")
.plugTo(parent, "overlayAlpha")
.setRange(0, 255)
.setValue(255)
.setPosition(80, 10)
.setSize(50, 10)
.setGroup(g1)
;
y+=50;
cp5.addBang("shot")
.setLabel("shot")
.setPosition(20, y)
.setSize(w-40, 20);
y+=50;
Group g3 = cp5.addGroup("g3")
.setLabel("Albums")
.setPosition(20, y)
.setSize(w-40, 100)
.setBackgroundColor(color(50))
;
cp5.addScrollableList("albumlist")
.setPosition(10, 10)
.setSize(130, 80)
.setGroup(g3)
.addItems(l)
.setType(ScrollableList.DROPDOWN)
.setOpen(false);
}
public void albumlist(int n) {
nSet =int(n);
selectSet(nSet);
}
public void controlEvent(ControlEvent theEvent) {
if (theEvent.isFrom("range")) {
higher = ceil(theEvent.getController().getArrayValue(0));
lower = ceil(theEvent.getController().getArrayValue(1));
}
}
public void clearMatrix() {
setRules();
}
public void reload() {
loadSource();
}
public void nextImage() {
nImg = (nImg+1)%totalImg;
loadSource();
}
public void backImage() {
nImg = (nImg-1)%totalImg;
}
public void sortMatrix(float[] a) {
rules[0][0] = boolean(floor(a[0]));
rules[0][1] = boolean(floor(a[1]));
rules[0][2] = boolean(floor(a[2]));
rules[1][0] = boolean(floor(a[3]));
rules[1][1] = boolean(floor(a[4]));
rules[1][2] = boolean(floor(a[5]));
rules[2][0] = boolean(floor(a[6]));
rules[2][1] = boolean(floor(a[7]));
rules[2][2] = boolean(floor(a[8]));
}
public void changeMode(int a) {
mode = a;
}
public void shot(){
printFrame=true;
println("shot");
}
public void draw() {
// NOTHING //
}
private ControlFrame() {
}
public ControlFrame(Object theParent, int theWidth, int theHeight) {
parent = theParent;
w = theWidth;
h = theHeight;
}
public ControlP5 control() {
return cp5;
}
ControlP5 cp5;
Object parent;
}