MrThoe

Untitled

Sep 22nd, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. /** Button Simple
  2. *
  3. * @Author: Allen Thoe
  4. */
  5.  
  6. //Global Variables
  7. var x, y;
  8. var grey;
  9. var showRect;
  10.  
  11. function setup() {
  12. createCanvas(400, 400);
  13. x = 60;
  14. y = 100;
  15. grey = 255;
  16. showRect = false; //Boolean -- 1 or 0
  17. }
  18.  
  19. function draw() {
  20. background(220);
  21. fill(grey); //Color of ellipse
  22. if(abs(mouseX - x) < 40 && abs(mouseY - y) < 20){
  23. //INSIDE THE BUTTON
  24. grey = 100;
  25. if(mouseIsPressed){
  26. //DO SOMETHING
  27. showRect = true;
  28. }
  29. } else {
  30. grey = 255;
  31. }
  32. ellipse(x, y, 80, 40); //rect(x, y, width, height, round)
  33. fill(0); //Black text
  34. text("Click Me", x-20, y+5);
  35. if(showRect){
  36. rect(220, 240, 100, 40);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment