Event called when canvas is resized

not sure why a event is needed,
if you make a resizable sketch you just check if it changed
the easy way

// example / demos / test / resize /

int mywidth=500, myheight=400;

void settings() {
  //  fullScreen();
  size(mywidth, myheight);
}


void setup() {
  //  size(400, 400);
  surface.setResizable(true);
  surface.setTitle("myTitle");
}

void draw() {
  background(255, 0, 0);
  ellipse(width/2, height/2, 100, 50); 
  if ( check_window() ) {
    println(" window changed to w: "+width+" h: "+height);
    mywidth = width;
    myheight = height;
  }
}

boolean check_window() {
  boolean changed = false;
  if ( mywidth != width )   changed = true;
  if ( myheight != height ) changed = true;
  return changed;
}


2 Likes