Logging when pressing a button
in
Contributed Library Questions
•
1 year ago
Dear all,
I would like to click a button, the rectangle rotates, and at the same time the text shows the rotation value each time the button is being pressed. for example, when I pressed the button for one time, it will display -90, if I were to press the second time, it will display -180 and so on and so forth. I try putting in a for loop but apparently it is not correct.
My syntaxes are as follow:
import processing.opengl.*;
import controlP5.*;
ControlP5 controlP5;
Button button1;
float rotation;
String msg0 = "Rotated by: ";
void setup() {
size(400, 400, OPENGL);
controlP5 = new ControlP5(this);
button1 = controlP5.addButton("Rotate", 1, 50, 50, 50, 50);
noStroke();
rectMode(CENTER);
}
void draw() {
background(0);
pushMatrix();
translate(width/2, height/2);
rotateZ(rotation);
fill(255);
rect(0, 0, 100, 150);
popMatrix();
fill(255);
text(msg0, 200, 100);
}
void Rotate()
{
rotation -= PI/2;
for (int i =0; i< 1000; i = i+90)
println(i);
}
Thank you in advanced:D
hanny
1