Created
September 29, 2016 04:56
-
-
Save chrisbodhi/55cfc0d61c4b5a0c2275b67e7ab75f2c to your computer and use it in GitHub Desktop.
mouseX experiments in Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
size(640, 360); | |
} | |
void draw() { | |
float transitionVal = float(mouseX) / width * 255; | |
// dragging the mouse from left to right changes the background color from white to black | |
background(255 - transitionVal); | |
rectMode(CENTER); | |
// dragging the mouse from left to right decreases the width of the rectangle, | |
// until it's zero at the center; at which point, it starts to increase again | |
// as the mouse keeps moving right | |
rect(width/2, height/2, abs(mouseX - width/2), 125); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment