Controller 001 alpha : Examples : slider_event_2
Controller controller;
BFont font;
int n1, n2;
void setup()
{
size(200, 200);
framerate(25);
font = loadFont("OCR-B.vlw.gz");
textFont(font, 128);
textMode(ALIGN_CENTER);
controller = new Controller(this, "hsliders: 4; vsliders: 4");
}
void loop()
{
background(32, 0, 127);
fill(160, 160, 0);
text(nf(n1, 3), width / 2, 88);
rect(0, height / 2, width, height / 2);
fill(32, 0, 127);
text(nf(n2, 3), width / 2, 188);
}
void controllerUpdated(ControllerEvent e)
{
if (e.getMessage() == "VALUE")
{
XSlider source = (XSlider) e.getSource();
if (e.getSource().getGroup() == controller.hsliders)
{
n1 = (int) round(source.getValue() * 100); // when converting floats to ints, it's better to do rounding before
}
else if (e.getSource().getGroup() == controller.vsliders)
{
n2 = (int) round(source.getValue() * 100);
}
}
}
top
|
home
|
bagel papa poule : tookit