how resize sketch without recompile

edited May 2018 in Questions about Code

hey! how can i change the sketch size without recompile? i try to make a button but not work. I use void settings() cos i`ve more that one canvas. i trying to change the main canvas.

int choiceSize = 0;

void settings() {
  //size(500, 500, P3D);
  //fullScreen(P3D);

  if (choiceSize==0) {
    fullScreen(P3D, 2);
  }
  if (choiceSize==1) {
    size(1000, 1000, P3D);
  }
  if (choiceSize==2) {
    size(720, 1280, P3D);
  }
}

Answers

  • final int W=640;
    
    
    void settings() {
      size(W, 360);
    }
    
    void setup() {
    
      surface.setResizable(true);
      noLoop();
    }
    
    void draw() {
      background(random(50, 200));
    }
    
    void mouseReleased() {
      surface.setSize((int)random(0.20*W, W), height);
    }
    

    Kf

  • thanks. I implement and it work, the window size change. but, the thing is that object and perspective arent display properlty . look that the perspective crash. ex: the ellipse is not perfect when i change the ratio.. how can i fix this?

  • Without seeing your code, I can only suggest this. I think you are using hard core values when defining the ellipse:

    ellipse(0,0,50,50);

    Try this

    ellipse(0,0,int(width*0.05),int(height*0.05));

    Does it solve your problem? Notice that translations should also keep in mind the screen size.

    Kf

Sign In or Register to comment.