Screen to PGraphic?

The main problem in real applications is that, if you are drawing to the canvas every frame and then copying all the pixels off, then you are always wiping the destination buffer every frame, so you lose the potential flexibility of having a drawable graphics buffer in the first place.

So this is better for a snapshot – which you can do anytime with g.copy() or just copy(), giving you a PImage. If you want to make that PImage into a PGraphics for further drawing, then in addition to copying pixels you may want to also copy the pixel density properties. See this example of clonePImageAsPGraphics:

…but then you might want to convert it just-in-time for drawing if you aren’t actually drawing to it every frame.

2 Likes