Fixed size with scroll

Hi :slight_smile:

I’m very new to processing. —noob alert—
For my college project I’m trying to create a background with a fixed size at first glance (2560x1600) but is in reality bigger than that (3840x3200), allowing you to scroll down & sideways by clicking and dragging your mouse.

I’ve looked for answers and I can’t really find anything that helps.
Thank you in advance!

Example:

float xos, yos;

void setup() {
  size(400, 400);
}

void draw() {
  background(0);
  translate(-xos, -yos);
  fill(0, 200, 0);
  ellipse(200, 200, 100, 100);
  fill(0, 0, 200);
  ellipse(600, 600, 100, 100);
}

void mouseDragged() {
  xos += pmouseX - mouseX;
  yos += pmouseY - mouseY;
  xos = constrain(xos,0,400);
  yos = constrain(yos,0,400);
  
}

Good luck with your project.

1 Like