p5.js
p5.js copied to clipboard
size() throws error with p5.Graphics
Most appropriate sub-area of p5.js?
- [x] Core/Environment/Rendering
Details about the bug:
- p5.js version: 1.1.9
- Web browser and version: latest Firefox and Chrome
- Operating System: macOS 14
- Steps to reproduce this:
p5.Graphics.size()
throws this error:
TypeError: setting getter-only property "canvas"
This is specific to p5.Graphics. Other p5.Element-derived objects can resize as expected.
Note that p5.Graphics.resizeCanvas()
is a perfectly functioning workaround for this but this should still be fixed or a friendlier error should be thrown.
there is nothing in reference page about size method
can I try to fix this issue ?
Sure @highonweb !
@highonweb thanks! I think the size()
method won't work for p5.Graphics because it needs a bit more than simply resizing the element, and so resizeCanvas()
is the correct method to use. To fix this issue, you could use a friendly error message to alert users trying to call this method to use resizeCanvas()
instead.
@stalgiag can you review my PR