Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int i = 0;
- int x = 10;
- int rectX, rectY;
- int rectSize = 25;
- int width =285;
- int height =285;
- color rectColor;
- boolean rectOver = false;
- //--//
- void setup() {
- size(600,600);
- background(0);
- rectColor = color(0);
- rectX = width/2-rectSize-10;
- rectY = height/2-rectSize/2;
- }
- void draw() {
- frameRate(5);
- for(int a = 15 ; a < 585 ; a = a + 20) {
- for(int i = 15 ; i < 585 ; i = i + 20) {
- fill(0,random(0,200),random(0,200));
- noStroke();
- rect(i,a,10,10);
- }
- }
- update(mouseX, mouseY);
- noStroke();
- if (rectOver) {
- background(rectColor);
- }
- }
- void update(int x, int y) {
- if ( overRect(rectX, rectY, rectSize, rectSize) ) {
- rectOver = true;
- }
- }
- boolean overRect(int x, int y, int width, int height) {
- if (mouseX >= x && mouseX <= x+width &&
- mouseY >= y && mouseY <= y+height) {
- return true;
- }
- }
- //╮( ˘_˘ )╭
- void mousePressed (){
- fill(random(0,200),0,random(0,200));
- redraw();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement