Hi there,
Have been struggling with this bit of code from the examples. I combined two sets of code from the ControlP5 examples but I can't seem to make this work.
I'm trying to learn about the Snapshot function that will help remember values. It works for all the parameters and even saves the JSON file correctly to call back when required.
It's just the ColorWheel that doesn't respond. Could anyone help me understand what I'm doing wrong here? Thanks!
import controlP5.*;
ControlP5 cp5;
float n = 50;
float s = 10;
float k = 100;
int c = color(100);//this variable does not get stored in the JSON file on pressing 'i' key
void setup() {
size(400, 600);
smooth();
cp5 = new ControlP5(this);
cp5.addNumberbox("n")
.setPosition(10, 10)
.setSize(42, 16)
.setMultiplier(0.1)
.setRange(10, 60)
.setValue(20)
;
cp5.addSlider("s")
.setPosition(10, 100)
.setSize(100, 20)
.setScrollSensitivity(0.01)
.setRange(60, 140)
.setValue(100)
;
cp5.addKnob("k")
.setPosition(200, 100)
.setRadius(50)
.setScrollSensitivity(0.001)
.setMin(60)
.setMax(140)
.setDisplayStyle(Controller.ARC)
;
cp5.addRange("r")
.setPosition(10, 200)
.setSize(100, 20)
.setRange(0, 200)
.setRangeValues(50, 100)
;
//snapshot does not seem to act in the same way for ColorWheel. Why is that?
cp5.addColorWheel("c", 10, 250, 200 ).
setRGB(color(128, 0, 255))
;
}
void draw() {
background(0);
}
void keyPressed() {
switch(key) {
case('1'):
cp5.getProperties().setSnapshot("hello1");
break;
case('a'):
cp5.getProperties().getSnapshot("hello1");
break;
case('z'):
cp5.getProperties().removeSnapshot("hello1");
break;
case('i'):
cp5.getProperties().saveSnapshot("hello1");
break;
case('o'):
cp5.getProperties().load("hello1.json");
break;
}
println(cp5.getProperties().getSnapshotIndices());
}