We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to create an indicator for the two buttons , which if the button " A " controlled will change the color of the ellipse of color 1 to color 2 , and if the button " B " controlled will change the color of the ellipse of color 2 to 1. I think the color of the variable ' x ' can represent value for color ellipse , but it does not work well , please help me resolve this. Thank You.
import controlP5.*;
import processing.serial.*;
ControlP5 cP5a;
ControlP5 cP5b;
color [] colors = new color[x];
void setup() {
size(100,100);
println(Serial.list());
cP5a = new ControlP5(this);
cP5a.addButton("A",1,10,10,30,30);
cP5b = new ControlP5(this);
cP5b.addButton("B",1,10,50,30,30);
}
void draw() {
background(#614DED);
fill('x');
ellipse(56, 46, 20, 20);
}
void controlEvent(ControlEvent theEvent) {
if(theEvent.isController()) {
print("control event from : "+theEvent.controller().name());
println(", value : "+theEvent.controller().value());
if(theEvent.controller().name()=="A") {
colors[x] = color(#3CF705);
}
if(theEvent.controller().name()=="B") {
colors[x] = color(#FA0A0E);
}
}
}