//sketch_Button import controlP5.*; ControlP5 cp5; int myColor = color(255); int c1,c2; float n; void setup() { size(400,400,P3D); noStroke(); cp5 = new ControlP5(this); cp5.addButton("colorA") .setValue(0) .setPosition(0,0) .setSize(60,19); cp5.addButton("colorB") .setValue(100) .setPosition(0,20) .setSize(60,19); cp5.addButton("colorC") .setPosition(0,40) .setSize(60,19) .setValue(50); } void draw() { pushMatrix(); lights(); background(255); myColor = lerpColor(c1,c2,n); n += (1-n)* 0.01; fill(myColor); translate(width / 2, height / 2); rotateY(map(mouseX, 0, width, -PI/1, PI/1)); rotateX(map(mouseY, 0, height, PI/1, -PI/1)); box(50,50,100); popMatrix(); } public void colorA(int theValue) { println("a button event from colorA: "+theValue); c1 = c2;n = 0; c2 = color(0,160,100); } public void colorB(int theValue) { println("a button event from colorB: "+theValue); c1 = c2;n = 0; c2 = color(150,0,0); } public void colorC(int theValue) { println("a button event from colorC: "+theValue); c1 = c2;n = 0; c2 = color(255,255,0); }