Surface Resize issues

Hi, I am having trouble changing the size of my surface in a sketch.

Basically I load an image, set the surface size to the size of the image then draw circles on the surface.

The issue is that Processing is actually scaling the surface after I draw the circles instead of before so if my image is 1000x1000 pixels and I start with a size of 100,100, everything gets scales 10x.

I would like to resize the surface prior to drawing the circles.

It seems like the resize doesn’t happen until the end of draw().

Is there any way round this?



img = loadImage(path);   
      int sx = img.width;
      int sy = img.height;
      surface.setSize(sx, sy);

      // now I add all my circles

maybe this helps?


Hey I think you just have to re draw you circles :slight_smile:

Here is the code I wrote:

PImage img;

boolean keyWasPressed = false;

void setup() {
  size(600, 600);
  //load the image on start so the programm dont have to load it while running.. 
  img = loadImage("");
void draw() {
  textAlign(CENTER, CENTER);
  text("PRESS A KEY", 0, 0, width, height);

  ellipse(200, 200, 30, 30);

  if (keyWasPressed) {
    //if key was pressed draw the image with alpha = 120
    tint(255, 120);
    image(img, 0, 0);
void keyPressed() {
  keyWasPressed = true;
  surface.setSize(img.width, img.height);
1 Like