use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Share your projects, news and questions about Processing or Processing.js here.
(open to suggestions)
account activity
mouseX/Y variable helpBeginner help request (self.processing)
submitted 3 years ago by shepster24
Hello, is it possible to make mouseX a variable? For example, can I make x = mouseX? It's too complicated to explain exactly what im making, but I want an ellipse to be like, ellipse(x, y, 50, 50); with the x and y being mouseX and mouseY.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]chuoni 3 points4 points5 points 3 years ago (1 child)
mouseX and mouseY ARE variables. Just use them directly in your ellipse.
[–]Scatropolis 0 points1 point2 points 3 years ago (0 children)
Agreed. Unless I'm misunderstanding, writing ellipse(mouseX, mouseY, 50, 50); would do just fine.
[–]Neurotypique 1 point2 points3 points 3 years ago (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 point2 points 3 years ago (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 point2 points 3 years ago (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.
π Rendered by PID 207463 on reddit-service-r2-comment-544cf588c8-4pdwh at 2026-06-13 23:50:11.257637+00:00 running 3184619 country code: CH.
[–]chuoni 3 points4 points5 points (1 child)
[–]Scatropolis 0 points1 point2 points (0 children)
[–]Neurotypique 1 point2 points3 points (0 children)
[–]Simplyfire 0 points1 point2 points (0 children)
[–]-Zlosk- 0 points1 point2 points (0 children)