hello, i am new to processing and have a somewhat basic question. i want this incredibly simple drawing tool where you can toggle a pixel on or off by pressing. HOWEVER, since the pixels are then so small, i want to have a zoom function so users can intuitively zoom in and continue to draw (at say 200%) and then zoom back out, with the pixels “appearing” to be in the same place, like you might zoom in or out of a map. does anyone have a solution for this or a tutorial that could help me? thank you so much.
In order to keep track of the drawn pixels and be able to move them around, we need to store them in an image separate from the normal drawing canvas. We can do that using either a PImage or a PGraphics. I’ll use a PGraphics since that then lets us use various drawing commands. We can then display our new canvas using image().
To be able to zoom, we’ll also want to track where we zoom, so I create variables viewX, viewY, and viewZoom. To separate drawing and moving, I use the left mouse button for drawing and right to move. The mouse wheel lets us zoom.
Thank you so so much!!! This is a HUGE help. I really appreciate you taking the time. Any suggestions for how to constrain it so it doesn’t reveal background?