Adjusting window size AND shape size

I want to code my program so that regardless of what the window size is modified to, the shape (rectangle) will also change according to the new size. In other words, the rectangle size and position should adjust if the programmer changes the window size.

My rectangle is also moving down the screen at one pixel at a time (which takes around 10 seconds to reach the bottom from the top).

I have tried numerous ways but I still can’t figure out how to achieve this. Thank you for your help!!

This is my code so far:

int travel = 0;

void setup() {
  size(1280, 720);
}

void draw() {
  background(240, 240, 240);
  fill(255, 147, 79);
  rect(0, travel, 90, 90);
  travel = travel + 1;
}
1 Like

You should use height and width

I understand that, but how would I apply them?

rect(0, travel, width/14, height/8);
1 Like