p5
p5 copied to clipboard
Scale is incorrect when window size is 360x360
Describe the bug The scale seems to be 1/2 when the window size is exactly 360x360.
To Reproduce Create a window that is 360x360. E.G.
from p5 import *
def setup():
size(360, 360)
def draw():
rect((0,0), width, height)
Expected behavior You would expect to see a white square cover the entire window. (Instead, you see a white square cover 1/4 of the window.
Screenshots
System information:
- p5 release (version number or latest commit): v0.5.0
- Python version: 3.7
- Operating system: MacOS 10.13.6
Additional context I've verified this problem on multiple machines and can only replicate it with 360x360 windows.
Could you check with the latest commit? I tried with the latest commit on Linux, and it gives the expected result(one fullscreen square).
Just tried it with the latest master. Same issue. Maybe it is mac specific?
Its working perfectly on my machine. I too use a Mac (Mojave):
Hmm, maybe its High Sierra specific?
It is a very odd error - what is magic about a size 360? (Although, that fact that it is 360 and not some other number makes me a bit suspicious - some weird interaction with a hardcoded value used for angle conversion?)
I just noticed: p5/p5/sketch/userspace.py
Has the following:
builtins.width = 360
builtins.height = 360
Any chance my issue is related to this?
@redfood, those are just the default parameters that get used when size()
is not called. We used to have this issue on the Mac sometime ago but it was fixed last summer or so. Could you double check if you're on the correct version of p5py?
I just ran install p5 -U
and it said everything was up to date. Just to double check I also downloaded the master from github and used it to replace my p5 in the site-packages
directory. I still have the issue. Is there any way to get p5 to report which version is running?
Is there any way to get p5 to report which version is running?
There is:
>>> import p5
>>> print(p5.__version__)
But if you downloaded the current version and had the same issue, it's possible that it's a p5py bug.
>>> import p5
>>> print(p5.__version__)
0.5.0
>>>
1/4 of the window
I wonder if that could somehow be a pixelDensity-related issue.
Just to be clear, with size(361, 361) the display is normal?
Just to be clear, with size(361, 361) the display is normal?
Yes- it works correctly with size(361, 361)
(it even works correctly with size(360, 361)
)
Similar behavior on a 2019 Macbook Pro, which has a Retina screen. p5 0.6.0 (latest release), Python 3.7.4.
25% square in bottom left @ 360x360, full window square (minus the last line) @ 361x360 or 360x361.
I'm able to reproduce this on p5 version 0.6.0, 2016 MacBook Pro (retina), macOS 10.12.6
The broken layout happens
- on exactly
size(360,360)
. It won't happen onsize(359, 359)
, orsize(360 361)
.
from p5 import *
def setup():
size(360,360)
def draw():
background(0)
rect((0,0),100,100)
if __name__ == '__main__':
run()
- OR, if you omit size / omit setup.
from p5 import *
def draw():
background(0)
rect((0,0),100,100)
if __name__ == '__main__':
run()
Expected: a black sketch, with a 100x100 rect in the upper left. Here it is at 360x361:

Instead, at 360x360 or with no size / no setup:
