how to use mouse events with simple functions
in
Programming Questions
•
1 year ago
i am a total rookie, so my apologies
i downloaded a program which follows the mouse around and draws circles....
void setup()
{
size(640, 360);
background(102);
smooth();
}
void draw()
{
// Call the variableEllipse() method and send it the
// parameters for the current mouse position
// and the previous mouse position
variableEllipse(mouseX, mouseY, pmouseX, pmouseY);
}
// The simple method variableEllipse() was created specifically
// for this program. It calculates the speed of the mouse
// and draws a small ellipse if the mouse is moving slowly
// and draws a large ellipse if the mouse is moving quickly
void variableEllipse(int x, int y, int px, int py)
{
float speed = abs(x-px) + abs(y-py);
stroke(speed);
ellipse(x, y, speed, speed);
}
i would like to make this function only work when the mouse is pressed... i tried a couple things, an if statement and just using the mousePressed fuction... but i don't think i understand how to implement this, is it a function that calls up the original function? or is it much easier than this?
once again, i apologize, i am a total beginner, i bought a book, and have messed around a bit... thanks in advance
1