window resizing in processing

Nikolaus Gradwohl2009-03-08T19:50:00+00:00

The following processing code shows how to resize a processing window from your code. the resizeApp methdo calculates the difference between the frame size and the size of the actual drawing area and adds it to the new size. then the application-frame is resized.

void setup() {
  size(320,200);
}

int col = 0;

void draw() {
  background(col);
  stroke(255,0,0);
  line(0,0,width, height);
  line(0,height,width,0);
}

void mousePressed() {
  if (col == 0) {
    resizeApp( 640, 400 );
    col = 255;
  } else {
    resizeApp( 320, 200 );
    col = 0;
  }
}

void keyPressed() {
  exit();
}

void resizeApp( int w, int h ) {
  int delta = frame.getHeight()-height;
   resize( w, h );
   frame.setSize( w, h + delta );
}
Tweet This! submit to reddit Digg! Tags: | no comments | no trackbacks

See also:

sketch experiment 7 - osc events
nested cubes in processing
processing phaseflower
Time Perception
de jong attractor

Trackbacks

Comments

Leave a response

Leave a comment