Zoom and save as png

I can save my canvas as a .png :slight_smile: how do I zoom it in first?
I am creating a D&D grid, I would like to save it so each square is 1 inch across.
I would like to save it with a transparent background.


Look at scale() in the reference

Use it before drawing the dungeon

Use translate to place the dungeon in the center

This is what I’m playing with:

click save
resizeCanvas(1200, 1200)
draw everything
resizeCanvas(600, 600)


this is not saving the png at 2 times the zoom, it is saving at normal zoom

Huh, it seems to work in this simple sketch:


click to save

I don’t think you need to zoom in to get your square section saved. I would use the get() function to get a specific section of your canvas and load this section into a PGraphics object. The final step is to save this PGraphics using save() as describe in the reference.

You can keep the size of the PGraphics (ok in p5js is the object return by createGraphics() function) to be the same dimensions as the ones used for the get() function. If you wanted to have a zoom in effect, you can increase the dimension of the PGraphics before you load the image there.


1 Like