How can I see the entire processing frame/surface if it is larger than the resolution of my monitor?

edited January 2018 in How To...

Hello, I like to generate and save large images using processing, much larger than the resolution of my monitor. However, that means that while my sketch is drawing, I can only see part of it.

For example, let's say that my sketch needs to render an image at 4000x4000. When it is done, it saves the image using save(). However, I want to be able to see what's going on as the sketch is being generated, but my screen is only 2560 x 1600.

Is there a way to zoom out so that I can see the entire image while it is been generated, but retain the high resolution I need as a final result?

I realize that I could pre-generate a smaller version, and then let it work on the larger version once I "approve it." However, that does not work for me for various reasons, one of them being that I don't want to do the work twice, even if the first time is at low-resolution.

Any ideas?

Tagged:

Answers

  • You need to implement your own zoom functions. Explore similar topics at:

    https://forum.processing.org/two/search?Search=panning

    Kf

  • edited January 2018

    If you just want to use your monitor as a shrunk preview (without panning around on a larger surface) then one approach is:

    1. Create a 4000x4000 PGraphics pg
    2. Draw to pg
    3. Assuming your sketch is in fullscreen mode(), draw a scaled image to the sketch canvas with image(pg, 0, 0, 1600, 1600) This will fit the image on your monitor. To center, translate by 480.
    4. When finished, save pg to disk.

    This scaling is expensive, so if you don't want the preview to consume too many resources during drawing you could decide to only refresh the preview every %n frames, e.g. once a second -- it really depends on what your preview needs and hardware resources are.

    One generic fit algorithm for shrinking any large image to any screen dimensions is to find the ratios of your canvas w/h to image w/h, then scale both sides of your image to whichever is the smaller ratio.

    wratio = width/pg.width;
    hratio = height/pg.height;
    scale = min(wratio/hratio);
    image(pg, 0, 0, pg.width*scale, pg.height*scale);
    
Sign In or Register to comment.