controlp5 no behavior
in
Contributed Library Questions
•
1 year ago
hi,
i have a running program for which i would like to implement a controlp5 interface. i have created the interface, but the values i am controlling are not being passed to my objects. i am using 2 sliders, 2 sliders with tickmarks and 2 check boxes.
here is my setup() code:
import controlP5.*;
import processing.opengl.*;
ControlP5 cp5;
CheckBox checkbox;
Slider sliderNumLines, sliderSpaceLines, sliderLineThickness, sliderSpeedD;
TriLine topTriLine;
TriLine bottomTriLine;
Timer timer;
float totalTime = 60000.0;
float rotX, rotY;
int numberOfLines = 19;
int spaceBetweenLines = 10;
int lineThickness = 1;
int speedDivisor = 1;
float direction = 1.0;
void setup()
{
size (1000, 1200, OPENGL);
frameRate(30);
cp5 = new ControlP5(this);
checkbox = cp5.addCheckBox("direction")
.setPosition(200, 110)
.setColorForeground(color(120))
.setColorActive(color(255))
.setColorLabel(color(187))
.setSize(20, 10)
.setItemsPerRow(1)
.setSpacingRow(10)
.setValue(1)
.addItem("TOP TRIANGLE DIRECTION", 1)
.addItem("BOTTOM TRIANGLE DIRECTION", 1);
sliderNumLines = cp5.addSlider("numberOfLines")
.setPosition(20, 20)
.setColorLabel(color(187))
.setSize(200, 10)
.setRange(19, 100);
sliderSpaceLines = cp5.addSlider("spaceBetweenLines")
.setPosition(20, 40)
.setColorLabel(color(187))
.setSize(200, 10)
.setRange(0, 20);
sliderLineThickness = cp5.addSlider("lineThickness")
.setPosition(20, 60)
.setColorLabel(color(187))
.setWidth(200)
.setRange(1, 10)
.setNumberOfTickMarks(10)
.setColorTickMark(color(187))
.snapToTickMarks(true)
.setSliderMode(Slider.FLEXIBLE);
sliderSpeedD = cp5.addSlider("speedDivisor")
.setPosition(20, 80)
.setColorLabel(color(187))
.setWidth(200)
.setRange(1, 20)
.setNumberOfTickMarks(20)
.setColorTickMark(color(187))
.snapToTickMarks(true)
.setSliderMode(Slider.FLEXIBLE);
topTriLine = new TriLine(190, 0, 6, numberOfLines, spaceBetweenLines, direction, speedDivisor);
bottomTriLine = new TriLine(190, 0, 6, numberOfLines, spaceBetweenLines, -direction, speedDivisor);
}
does controlp5 not work with variables passed to classes and variables that are not directly accessed in draw()? do i need to implement event listeners for the sliders and check boxes?
thanks in advance.
destro
i have a running program for which i would like to implement a controlp5 interface. i have created the interface, but the values i am controlling are not being passed to my objects. i am using 2 sliders, 2 sliders with tickmarks and 2 check boxes.
here is my setup() code:
import controlP5.*;
import processing.opengl.*;
ControlP5 cp5;
CheckBox checkbox;
Slider sliderNumLines, sliderSpaceLines, sliderLineThickness, sliderSpeedD;
TriLine topTriLine;
TriLine bottomTriLine;
Timer timer;
float totalTime = 60000.0;
float rotX, rotY;
int numberOfLines = 19;
int spaceBetweenLines = 10;
int lineThickness = 1;
int speedDivisor = 1;
float direction = 1.0;
void setup()
{
size (1000, 1200, OPENGL);
frameRate(30);
cp5 = new ControlP5(this);
checkbox = cp5.addCheckBox("direction")
.setPosition(200, 110)
.setColorForeground(color(120))
.setColorActive(color(255))
.setColorLabel(color(187))
.setSize(20, 10)
.setItemsPerRow(1)
.setSpacingRow(10)
.setValue(1)
.addItem("TOP TRIANGLE DIRECTION", 1)
.addItem("BOTTOM TRIANGLE DIRECTION", 1);
sliderNumLines = cp5.addSlider("numberOfLines")
.setPosition(20, 20)
.setColorLabel(color(187))
.setSize(200, 10)
.setRange(19, 100);
sliderSpaceLines = cp5.addSlider("spaceBetweenLines")
.setPosition(20, 40)
.setColorLabel(color(187))
.setSize(200, 10)
.setRange(0, 20);
sliderLineThickness = cp5.addSlider("lineThickness")
.setPosition(20, 60)
.setColorLabel(color(187))
.setWidth(200)
.setRange(1, 10)
.setNumberOfTickMarks(10)
.setColorTickMark(color(187))
.snapToTickMarks(true)
.setSliderMode(Slider.FLEXIBLE);
sliderSpeedD = cp5.addSlider("speedDivisor")
.setPosition(20, 80)
.setColorLabel(color(187))
.setWidth(200)
.setRange(1, 20)
.setNumberOfTickMarks(20)
.setColorTickMark(color(187))
.snapToTickMarks(true)
.setSliderMode(Slider.FLEXIBLE);
topTriLine = new TriLine(190, 0, 6, numberOfLines, spaceBetweenLines, direction, speedDivisor);
bottomTriLine = new TriLine(190, 0, 6, numberOfLines, spaceBetweenLines, -direction, speedDivisor);
}
does controlp5 not work with variables passed to classes and variables that are not directly accessed in draw()? do i need to implement event listeners for the sliders and check boxes?
thanks in advance.
destro
1