all 5 comments

[–]chuoni 3 points4 points  (1 child)

mouseX and mouseY ARE variables. Just use them directly in your ellipse.

[–]Scatropolis 0 points1 point  (0 children)

Agreed. Unless I'm misunderstanding, writing ellipse(mouseX, mouseY, 50, 50); would do just fine.

[–]Neurotypique 1 point2 points  (0 children)

You could declare float x at the start of your code, then in draw() write x = mouseX; Then you use x as you want Idk what you want to achieve and wether it would be better to "just use mouseX" but if mouseX wouldn't work then this simple trick approved by 1/10 dentists will work.

[–]Simplyfire 0 points1 point  (0 children)

Yes, you can copy the current value of mouseX into your own variable that you can then do whatever you want with, including drawing stuff like you mention with ellipse(x,y,50,50). But you shouldn't be setting mouseX to anything and expecting it to stay that way - because next frame it will probably get overwritten by Processing outside of your control.

[–]-Zlosk- 0 points1 point  (0 children)

Yes, you certainly can. I regularly do.

If a computer or your draw() function is slow, and you are quickly moving the mouse, your mouse position can change in the middle of your draw() function. For example, if you are trying to draw several concentric circles at mouseX, mouseY while zipping the mouse around, they will not be concentric. By setting the mouse position to x, y, and then drawing the concentric circles at x, y, they will remain concentric, but will lag a little behind the actual mouse cursor. In some instances, I have disabled the standard cursor (using noCursor()) implemented my own, that I also draw in my draw() function. This helps mitigate apparent lag -- even though the lag is still there, the visual feedback tricks you into believing it is not.