import controlP5.*;
boolean button1 = false, button2 = false, button3 = false;
ControlP5 cp5;
float bg = random(255);
void setup() {
size(1200, 750);
cp5 = new ControlP5(this);
cp5.addButton("A")
.setPosition(100, 100)
.setSize(10, 10);
cp5.addButton("B")
.setPosition(200, 200)
.setSize(10, 10)
;
cp5.addButton("buttonC")
.setPosition(300, 300)
.setSize(19, 19)
;
}
void draw() {
background(bg);
if ((button1 == true) && (button2 == true)); {
line(100,100,200,200);
}
if (button1 == true) {
pushMatrix();
translate(105, 105);
rotate(frameCount / -100.0);
star(0, 0, 10, 25, 5);
popMatrix();
} if (button2 == true) {
pushMatrix();
translate(205, 205);
rotate(frameCount / -100.0);
star(0, 0, 10, 25, 5);
popMatrix();
}
}
public void A() {
println("hello" + button1);
button1= true;
}
public void B() {
println("hellAAAAo" + millis());
bg = random(255);
button2= true;
}
public void buttonC() {
println("hello" + millis());
bg = random(255);
button3= true;
}
void star(float x, float y, float radius1, float radius2, int npoints) {
float angle = TWO_PI / npoints;
float halfAngle = angle/2.0;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius2;
float sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a+halfAngle) * radius1;
sy = y + sin(a+halfAngle) * radius1;
vertex(sx, sy);
}
endShape(CLOSE);
}
if ((button1 == true) && (button2 == true)); {
line(100,100,200,200);
ive played with this for some time but i cant get to grips with why the line is being drawn at the start of the sketch.
thanks for any advice