-
Notifications
You must be signed in to change notification settings - Fork 0
/
controls.pde
40 lines (34 loc) · 1.16 KB
/
controls.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
import controlP5.*;
class Controls {
private ControlP5 cp5;
Toggle useColorsToggle;
Slider maxIterationsSlider;
void init(PApplet a) {
cp5 = new ControlP5(a);
useColorsToggle = cp5.addToggle("Colored");
useColorsToggle.setPosition(10, 10);
useColorsToggle.setSize(20, 20);
useColorsToggle.addListener(new ControlListener() {
public void controlEvent(ControlEvent event) {
useColors = event.getValue() > 0;
useColorsToggle.setColorCaptionLabel(useColors ? color(255) : color(255, 0, 0));
maxIterationsSlider.setColorCaptionLabel(useColors ? color(255) : color(255, 0, 0));
repaint = true;
}
});
maxIterationsSlider = cp5.addSlider("Iterations");
maxIterationsSlider.setPosition(10, 50);
maxIterationsSlider.setRange(1, 1000);
maxIterationsSlider.addListener(new ControlListener() {
public void controlEvent(ControlEvent event) {
maxIterations = int(event.getValue());
repaint = true;
}
});
useColorsToggle.setValue(useColors);
maxIterationsSlider.setValue(maxIterations);
}
boolean isMouseOver() {
return cp5.isMouseOver();
}
}