-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
set() doesn't do anything when passed non-integer numbers #1159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is kind of tangential but which browser are you using? I just ran your sketch. Everything seems fine. mouseX mouseY are integers in my browser. Take a look at mouseX and mouseY in the following sketch:
|
Oh, so I think this is actually a bit related to #974 (comment)... Basically, on either Firefox or Chrome, when you zoom the page just the slightest bit (Ctrl-+/⌘-+), I suppose another alternative would be to force |
I just had a pull request merged where I called Math.floor() on decimal values passed into get(). set() and get() should probably be consistent in their handling, whatever we do. I saw that you called ceil() in that devicePixelRatio patch. What was you reasoning? I chose floor() because I figured if you took the conservative guess you have less of a chance going past your array length. But I'd be happy to change that for a more compelling reason. |
Oh cool! Does that mean this issue is fixed and we should close it? Which PR was it?
Good question--my reasoning behind using So, that said, my thinking was that if we want the p5 canvas to look as crisp as possible, it's better (albeit more expensive) to act as though the user has a slightly higher-density display than they actually do and then allow the browser to downscale it accordingly via CSS, instead of the other way around (in which case the browser would be upscaling via CSS, potentially making things look a bit blurry). So that was my thinking, but I could easily be mistaken, so let me know if you disagree! |
hey @toolness, regarding your questions about set... |
The following simple sketch didn't work for me:
This puzzled me for quite some time until I realized that
mouseX
andmouseY
aren't integers on my browser--they're floats!Should
set()
automatically callMath.floor()
on its arguments to coerce them to integers? Or will the friendly error system (#971) log an error to the console once it's fully operational again?Also, I didn't realize that there's another existing p5 method called
point()
. I wonder if it might be useful to mention it in the documentation forset()
(and vice versa) and maybe give some guidelines about when you might want to use one over the other?The text was updated successfully, but these errors were encountered: