# Processing resizing and changing sketch to and from fullScreen() mid sketch

**URL:** https://discourse.processing.org/t/processing-resizing-and-changing-sketch-to-and-from-fullscreen-mid-sketch/24005
**Category:** Gallery
**Created:** [September 21, 2020, 9:02pm UTC](https://discourse.processing.org/t/processing-resizing-and-changing-sketch-to-and-from-fullscreen-mid-sketch/24005 "2020-09-21T21:02:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kikomali2517](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kikomali2517](https://discourse.processing.org/u/kikomali2517)
#### Post date: [September 21, 2020, 9:02pm UTC](https://discourse.processing.org/t/processing-resizing-and-changing-sketch-to-and-from-fullscreen-mid-sketch/24005/1 "2020-09-21T21:02:18Z")

</div>

This might not sound useful but It took me a some time to get this working so I figured someone might find it useful.

Here is the code to be able to resize the sketch and switch it to and from fullscreen while it is running:

```auto
void setup(){
   fullScreen();

   surface.setResizable(false);
   surface.setAlwaysOnTop(true);
}

// Sets the x and y position of the screen aswell as the width and height
void screen(int x, int y, int w, int h){
  surface.setLocation(x, y);
  surface.setSize(w, h);
}

//Makes sketch fullscreen
void fullscreen(){
  surface.setLocation(0, 0);
  surface.setSize(displayWidth, displayHeight);
}

```

Example code:

```auto
void setup(){
  fullScreen();
  
  surface.setResizable(false);
  surface.setAlwaysOnTop(true);
  
  screen(200, 200, 400, 400); // Sketch is windowed
}

void screen(int x, int y, int w, int h){
  surface.setLocation(x, y);
  surface.setSize(w, h);
}

void fullscreen(){
  surface.setLocation(0, 0);
  surface.setSize(displayWidth, displayHeight);
}

void draw(){
  if (frameCount < frameRate * 4){
    screen(200 + int(200 * (frameCount / (frameRate * 4))), 200, 400, 400); // Window is moving right
  }
  else if (frameCount >= frameRate * 4 && frameCount <= frameRate * 4 + 10) {
    fullscreen();
  }
}

```

Tested on windows processing 3.5.3
