Thursday 5 November 2015

Processing GUI Button

Code:
import controlP5.*;
ControlP5 controlP5;

int buttonValue = 0;
void setup() {
size(400,400);
controlP5 = new ControlP5(this);
controlP5.addButton("White").setValue(255).setPosition(100,100).setSize(200,19);
controlP5.addButton("Black").setValue(0).setPosition(100,120).setSize(200,19);
}
void draw() {
background(buttonValue);
}

void controlEvent(ControlEvent event) {
  println("the Event Triggered is");
println(event.getName());
}



public void White( ){
println("white button");
buttonValue = 255;
}
public void Black(){
println("black button");
buttonValue = 0;
}

Output:


No comments:

Post a Comment