-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.js
62 lines (56 loc) · 1.16 KB
/
ui.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
let button, record, snap, fps;
function setupUI() {
// Normal Buttons
button = select('#toggleLoop');
button.mousePressed(toggleLoop);
record = select('#record');
record.mousePressed(toggleRecord);
reset = select('#reset');
reset.mousePressed(initSketch);
snap = select('#saveFrame');
snap.mousePressed(saveImage);
fps = select('#fps');
// Control UI
up = select('#ctl-up');
down = select('#ctl-down');
left = select('#ctl-left');
right = select('#ctl-right');
zoomIn = select('#ctl-zoomIn');
zoomOut = select('#ctl-zoomOut');
}
function toggleLoop() {
if (isLoop) {
noLoop();
isLoop = false;
} else {
loop();
isLoop = true;
}
}
function toggleRecord() {
if (isRecording) {
isRecording = false;
save = true;
} else {
isRecording = true;
save = false;
}
}
function clearCanvas() {
clear();
background(51);
}
function saveImage() {
if (!isLoop) {
toggleLoop();
captureFrame();
toggleLoop();
} else {
captureFrame();
}
}
function captureFrame() {
filename =
'mandelbrot_' + str(year()) + str(month() + day() + hour() + minute() + second());
saveCanvas(filename, 'PNG');
}