SHARE
TWEET

Untitled

cryingrobot Feb 27th, 2018 171 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     int i = 0;
  2.     int x = 10;
  3.     int rectX, rectY;
  4.     int rectSize = 25;
  5.     int width =285;
  6.     int height =285;
  7.    
  8.     color rectColor;
  9.     boolean rectOver = false;
  10.    
  11.     //--//
  12.    
  13.     void setup() {
  14.        size(600,600);
  15.        background(0);
  16.        
  17.        rectColor = color(0);
  18.        rectX = width/2-rectSize-10;
  19.        rectY = height/2-rectSize/2;
  20.     }
  21.    
  22.     void draw() {
  23.       frameRate(5);
  24.       for(int a = 15 ; a < 585 ; a = a + 20) {
  25.         for(int i = 15 ; i < 585 ; i = i + 20) {
  26.           fill(0,random(0,200),random(0,200));
  27.           noStroke();
  28.           rect(i,a,10,10);
  29.         }
  30.       }
  31.       update(mouseX, mouseY);
  32.    
  33.       noStroke();
  34.       if (rectOver) {
  35.         background(rectColor);
  36.       }
  37.     }
  38.    
  39.     void update(int x, int y) {
  40.       if ( overRect(rectX, rectY, rectSize, rectSize) ) {
  41.         rectOver = true;
  42.       }
  43.     }
  44.      
  45.     boolean overRect(int x, int y, int width, int height) {
  46.       if (mouseX >= x && mouseX <= x+width &&
  47.           mouseY >= y && mouseY <= y+height) {
  48.         return true;
  49.           }
  50.     }
  51.          
  52.    
  53.          
  54.     //╮( ˘_˘ )╭
  55.     void mousePressed (){
  56.       fill(random(0,200),0,random(0,200));
  57.       redraw();
  58.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top