controlP5 Slider2D questions
in
Contributed Library Questions
•
1 year ago
I downloaded the new controlP5. Fantastic work! The new dot syntax is an awesome improvement. It makes setting the controls a lot clearer. Also there seems to be a ton of new features and a lot of updated examples. Very promising.
I have a few questions about the Slider2D (see the example below):
Code Example
I have a few questions about the Slider2D (see the example below):
- How to set the initial values when the range is set to -1,1?
- How to set the decimal precision of the display?
- Is is possible to disable the lines/rect display showing the current value?
Code Example
- import controlP5.*;
- ControlP5 cp5;
- Slider2D s;
- void setup() {
- size(200,200);
- cp5 = new ControlP5(this);
- s = cp5.addSlider2D("direction")
- .setPosition(50,50)
- .setSize(100,100)
- // Q1: setting a negative minX, minY (is this the right way to set the range?)
- .setMinX(-1).setMaxX(1)
- .setMinY(-1).setMaxY(1)
- // seems to break setArrayValue during initialization
- .setArrayValue(new float[] {0, 0}) // sets value -1,-1. See console println below.
- // Q2: how to set setDecimalPrecision of the display in the bottom right? I tried this...
- .setDecimalPrecision(2)
- // Q3: how to disable/make invisible display lines and/or rect?
- ;
- println(s.getArrayValue());
- cp5.setAutoDraw(false);
- smooth();
- }
- void draw() {
- background(0);
- cp5.draw();
- // I'd like to have this kind of display, can I turn off the default display with lines and a rect?
- translate(100, 100);
- line(0, 0, s.getArrayValue(0)*50, s.getArrayValue(1)*50);
- }
1