Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. //Aven,02/26/2017
  2. //Interactive Installation
  3. //New Media, WPP, SADA
  4.  
  5.  
  6. float x1, y1, size1 = 50, x2, y2, size2 = 30;
  7. color button1Color = color(100);
  8. color button2Color = color(100);
  9.  
  10. void setup() {
  11. size(400, 400);
  12. stroke(0);
  13. strokeWeight(1);
  14. x1 = width/2;
  15. y1 = height/2;
  16. x2 = width/2 + 100;
  17. y2 = height/2;
  18. }
  19.  
  20.  
  21. void draw() {
  22. background(100);
  23. //size = sin(frameCount*0.02)*60 + 90;
  24. fill(button1Color);
  25. ellipse(x1, y1, size1, size1);
  26. fill(button2Color);
  27. ellipse(x2, y2, size2, size2);
  28.  
  29. float distance1 = dist(x1, y1, mouseX, mouseY);
  30. if ( distance1 < size1/2) { //mouse hover
  31. button1Color = color(255, 0, 0);
  32. if (mousePressed) {
  33. button1Color = color(random(255), random(255), random(255));
  34. }
  35. } else {
  36. button1Color = color(100);
  37. }
  38. float distance2 = dist(x2, y2, mouseX, mouseY);
  39. if ( distance2 < size2/2) { //mouse hover
  40. button2Color = color(255, 0, 0);
  41. if (mousePressed) {
  42. button2Color = color(random(255), random(255), random(255));
  43. }
  44. } else {
  45. button2Color = color(100);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement