// Template Project 1
// Basic template displaying the position of the
// cursor on the lower border of the window
// Use "mx" as the only changing variable for the project
// 14 October 2004
float mx = 0.0;
void setup()
{
size(600, 300);
framerate(60);
}
void draw()
{
background(204);
marker();
}
void marker()
{
// Set the location of marker
float dif = mouseX - mx;
if(abs(dif) > 1.0) {
mx = mx + dif/8.0;
}
// Keep the marker on the screen
mx = constrain(mx, 1, width-1);
// Draw bottom rectangle
noStroke();
fill(255);
rect(0, height-5, width, 5);
// Draw bottom positional marker
fill(0);
rect(mx-2, height-5, 4, 5);
}