Skip to content

Instantly share code, notes, and snippets.

@fjenett
Created March 31, 2010 06:53
Show Gist options
  • Save fjenett/350021 to your computer and use it in GitHub Desktop.
Save fjenett/350021 to your computer and use it in GitHub Desktop.
// which part of the screen is my mouse in?
int grid;
void setup ()
{
size( 500, 500 );
grid = 3;
}
void draw ()
{
background(205);
int rx = mouseX / (width/grid); // should precalc width/grid, height/grid
int ry = mouseY / (height/grid);
rect( rx*(width/grid), ry*(height/grid), (width/grid), (height/grid) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment