mardi 13 décembre 2011

controlP5 slider

Code processing


import controlP5.*;

ControlP5 controlP5;

public int myColorRect = 200;

public int myColorBackground = 100;


void setup() {
size(400,400);
frameRate(25);
controlP5 = new ControlP5(this);
controlP5.addSlider("sliderA",100,200,100,100,260,100,14).setId(4);
controlP5.addTextfield("textA",100,290,100,20).setId(5);

}

void draw() {
background(myColorBackground);
fill(myColorRect);
rect(0,0,width,100);
}


// a slider event will change the value of textfield textA
public void sliderA(int theValue) {
((Textfield)controlP5.controller("textA")).setValue(""+theValue);
}

// for every change in textfield textA, this function will be called
public void textA(String theValue) {
println("### got an event from textA : "+theValue);
}

public void controlEvent(ControlEvent theEvent) {
println("got a control event from controller with id "+theEvent.controller().id());
}

Aucun commentaire:

Enregistrer un commentaire