Thanks Giles. That worked out fine.
Having sorted this out, I came across another problem. It seems that in Processing while drawing in the draw() function, the variabels mouseX and mouseY give irregular mouse positions (or measures at irregular intervals of time), while drawing inside mouseMoved() gives much more regular mouse positions.
Check out the following programs:
Code:void setup() {
size(1000, 800);
fill(0);
}
void draw() {
ellipse(mouseX, mouseY, 10, 10);
}
versus:
Code:void setup() {
size(1000, 800);
fill(0);
}
void draw() {
}
void mouseMoved(){
ellipse(mouseX, mouseY, 10, 10);
}
The latter will draw circles with much more regular divisions between the dots. The former tends to draw on irregular moments. I have tested both with the same movement and speed of my mouse.
Can anyone give me an explanation why the one differs from the other? I would like to use draw() in my program, but with the regular intervals of mouseX and mouseY measures.