We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everybody.
I can't find where is the problem with my sketch. Every time I resize the browser's window, the drawing made with line(pmouseX, pmouseY, mouseX, mouseY) disappears. Is this normal? How could I avoid it?
Here is the Pen from it: https://codepen.io/skmecs/pen/LWapZJ
thank you all in advance
best regards, Gil
Answers
As a workaround, you should consider createGraphics():
http://p5js.org/reference/#/p5/createGraphics
Don't forget to resize() it inside windowResized() as well:
http://p5js.org/reference/#/p5.Image/resize
Thanks GotoLoop
CreateGraphics worked to make the drawing not disappear, but I couldn't realize how to resize it. Resize works for image but not for createGraphics
Just maybe method size() might work on it: http://p5js.org/reference/#/p5.Element/size
Or try this 1 out:
pg._renderer.resize(width, height);
. ~:>Unfortunately none of those options work. Both have made the drawing disappear when resizing the window.
Using size() while drawing in the pg, a copy of it is made in the canvas. Weird! pg._renderer.resize(width, height) just didn't do the trick.
thanks again
https://GitHub.com/processing/p5.js/issues
Well, here is the issue in Github for future reference: https://github.com/processing/p5.js/issues/1876
@GoToLoop
Is it possible to capture the content of the canvas before it is resized with a PGraphics object and re-draw right after? Not much experience in p5.js....
Kf
Yes, w/ method get(): http://p5js.org/reference/#/p5.Image/get
Extremely unoptimized but, here's some workaround I've just come up w/: ^#(^