simple code to create button
in
Programming Questions
•
3 months ago
I would like to place the button in the middle of the window. Where did I go wrong?
float x = width/2;
float y = height/2;
Other times if I declared :
I could do it...
example:
- float x = width/2;
- float y = height/2;
- float w = 150;
- float h = 80;
- void setup(){
- size(500,500);
- background(255);
- stroke(0);
- noFill();
- }
- void draw(){
- background(255);
- rect(x,y,w,h);
- fill(134);
- if(mousePressed){
- if(mouseX>x && mouseX <x+w && mouseY>y && mouseY <y+h){
- println("The mouse is pressed and over the button");
- fill(232,43,45);
- }
- }
- }
1