Open manoloide opened 7 years ago
Not your mistake, color wheel is not included in save properties.
The range of controllers implementing save/load properties currently includes Slider, Knob, Numberbox, Toggle, Checkbox, RadioButton, Textlabel, Matrix,Range, textarea, ListBox, Dropdown, colorPicker.
To save colors from the colorwheel you could try using snapshots - though I've never got the hang of snapshots and just use getRGB() and serialize it to json.
I had the same problem but I came up with a workaround so that ColorWheels are saved.
It involves:
Annoying, but it works.
import controlP5.*;
ControlP5 cp5;
public color c = color(200);
void setup() {
size(400, 400);
cp5 = new ControlP5(this);
ColorWheel cw = cp5.addColorWheel("c", 20, 40, 150 );
// 1. Modify the ColorWheel properties:
// ColorWheels incorrectly set up their internal property value as ArrayValue.
// It should instead be a "value":
cw.registerProperty("value");
cw.removeProperty("ArrayValue");
cp5.addButton("b1", 0, 20, 20, 80, 12).setLabel("save setA");
cp5.addButton("b2", 0, 100, 20, 80, 12).setLabel("load setA");
}
void draw() {
background(0);
}
void b1(float v) {
cp5.saveProperties("test");
}
void b2(float v) {
cp5.loadProperties("test");
// 2. Connect the loaded property with your ColorWheel and the backing variable:
ColorWheel cw = (ColorWheel) gui.getController("c");
cw.setRGB((int) cw.getValue());
c = (int) cw.getValue();
}
ColorWheels incorrectly set up their internal property value as ArrayValue.
Good find. Do you mean that a pull request changing line 370 here is all it would take to fix the issue? Or might that break something else?
Good find. Do you mean that a pull request changing line 370 here is all it would take to fix the issue? Or might that break something else?
I just tested the change on a local copy of this repo and it works as its supposed to.
Interesting that it works. I asked because I'm not familiar with the cp5 codebase -- so not sure why some of those registerProperties are marked "value" and others "arrayValue", or why this is Legacy.
But if it works -- maybe submit a pull request?
I'm wanting to save ColorWheel content and it does not work for me, maybe it's my mistake. When I look inside the json the array is empty.