Processing 3: Resizable?

In processing 2, there was a way to make the frame resizable using:

void init() { super.init(); frame.setResizable(true); }

Is there a way to do this in processing 3.x?

Note: The PSurface Libraries might of something, but I have no idea how to use them.

Answers

  • What happened when you tried that in the latest version?

    This works fine for me in the latest:

    void setup(){
      size(200, 200);
      frame.setResizable(true);
    }
    
    void draw(){
      background(0);
      ellipse(width/2, height/2, 20, 20);
    }
    

    You get a little warning saying to use surface instead of frame though, which is easy enough advice to follow:

    void setup(){
      size(200, 200);
      surface.setResizable(true);
    }
    
    void draw(){
      background(0);
      ellipse(width/2, height/2, 20, 20);
    }
    
  • Here's an example that has worked for me:

    PImage img;
    String path ="";
     
    void setup() {
      size(400, 200);
      surface.setResizable(true);
     
      text("click window to load an image", 10, 100);
    }
     
    void draw() {
      if (img != null) {
        image(img, 0, 0);
      }
    }
     
    void handleImage(File selection) {
      if (selection== null) {
        println ("nono");
      } 
      else {
        path = selection.getAbsolutePath();
        img = loadImage(path);
        surface.setSize(img.width, img.height);
      }
    }
     
    void mouseClicked() {
      img = null;
      selectInput("select an image", "handleImage");
    }
    
  • Thanks, it works now!

Sign In or Register to comment.