Skip to content

Instantly share code, notes, and snippets.

@chrisbodhi
Created September 29, 2016 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbodhi/55cfc0d61c4b5a0c2275b67e7ab75f2c to your computer and use it in GitHub Desktop.
Save chrisbodhi/55cfc0d61c4b5a0c2275b67e7ab75f2c to your computer and use it in GitHub Desktop.
mouseX experiments in Processing
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