Guest User

Untitled

a guest
Oct 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. //change the color of an ellipse from black to white if the mouse is hovering over it
  2. int circleColor;
  3.  
  4. void setup() {
  5. size(700, 700);
  6. noStroke();
  7. }
  8.  
  9. void draw() {
  10. background(255);
  11.  
  12.  
  13. //loop 36 times in x and y
  14. for (int i = 0; i <= width; i += width/35) {
  15. for (int j = 0; j <= height; j += height/35) {
  16. fill(circleColor);
  17. ellipse(i, j, width/35, height/35);
  18.  
  19. float d = dist(mouseX, mouseY, i, j);
  20. if (d<=width/50) {
  21. circleColor = color(255);
  22. } else {
  23. circleColor = color(0);
  24. }
  25. if (d<=height/50) {
  26. circleColor = color(255);
  27. } else {
  28. circleColor = color(0);
  29. }
  30. }
  31. }
  32. }
Add Comment
Please, Sign In to add comment