Charlene - H

By Charlene
// The gray square rotates around the cursor continuously float angle; int x = 0; int y = 0; int w = 0; int h = 0; void setup() { size(400, 400); background(0); smooth(); } void draw() { background(0); translate(mouseX, mouseY); rotate(angle); angle = angle + 360; if (mousePressed == true) { // The gray square becomes darker when the mouse is pressed fill(25); } else { fill(120); } rect(x, y, w, h); } // The gray square is bigger and closer to the cursor when the x-value is smaller // It's smaller and farther to the cursor when the x-value is bigger void mouseMoved() { if((mouseX > 0) && (mouseX < 100)) { x = 0; y = 0; w = 70; h = 70; } else if ((mouseX > 100) && (mouseX < 200)) { x = 20; y = 20; w = 50; h = 50; } else if ((mouseX > 200) && (mouseX < 300)) { x = 40; y = 40; w = 30; h = 30; } else if ((mouseX > 300) && (mouseX < 400)) { x = 60; y = 60; w = 10; h = 10; } }

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*