Resize sketch window

Hi I have a sketch for a print canvas with a huge dimension of 7078x7087 pixels. I want to draw on it and I want to have the whole view of the sketch. My question is can I resize the sketch window without cropping it more like a zoom out option. Thanks

Answers

  • How exactly? :O

  • Draw whatever you want on the PGraphics buffer. Then display it in your sketch window with image(buffer, 0, 0, width, height).
    If you provide some code, I'll tell you what to do.

  • void setup () { size (7087, 7087); background (255);

    }

    void draw(){ ellipse (mouseX, mouseY, 50,50);

    }

  • edited February 2017

    This demo shows digital zoom. Click on the sketch to toggle between full image, zoom factor 1 or zoom factor 2. Notice the mouse coordinate system is not properly map when zoomed in.

    Kf

    PGraphics pg;
    boolean zoomNow=false;
    
    void setup() { 
      size(600, 600);  
      pg=createGraphics(width, height);
      imageMode(CENTER);
    } 
    void draw() { 
      background(250, 250, 25);
      pg.beginDraw(); 
      //pg.translate(pg.width/2, pg.height/2); 
      pg.background(0); 
      pg.fill(color(25,25,250));
      pg.rect(width/4,height/4,width/2,height/2);
      pg.fill(color(frameCount%256));
      pg.ellipse (mouseX, mouseY, 50, 50);
      pg.endDraw();  
    
      if (zoomNow==false)
       image(pg, width/2, height/2);
      else
       //NOTE: Get uses CORNERS always, not matter what imageMode is set to
       image(pg.get(pg.width/4, pg.height/4,pg.width/4*3, pg.height/4*3), width/2, height/2,width, height);
    }
    
    void mouseReleased() {
      zoomNow=!zoomNow;
    }
    
  • Modified @kfrajer's code to allow a PGraphics object with twice the dimensions of the sketch window.

    PGraphics pg;
    boolean zoomNow=false;
    
    void setup() { 
      size(600, 600);  
      pg=createGraphics(width*2, height*2);
      imageMode(CENTER);
    } 
    void draw() { 
      background(250, 250, 25);
      pg.beginDraw(); 
      //pg.translate(pg.width/2, pg.height/2); 
      pg.background(0); 
      pg.fill(color(frameCount%256));
      pg.ellipse (mouseX*2, mouseY*2, 100, 100);
      pg.endDraw();  
    
      if (zoomNow==false)
       image(pg, width/2, height/2, width, height);
      else
       //NOTE: Get uses CORNERS always, not matter what imageMode is set to
       image(pg.get(pg.width/4, pg.height/4,pg.width/4*3, pg.height/4*3), width/2, height/2);
    }
    
    void mouseReleased() {
      zoomNow=!zoomNow;
    }
    
Sign In or Register to comment.