Why doesn't this create a 100x100 square : rect(mouseX, mouseY, mouseX + 100, mouseY + 100);

edited January 2015 in Questions about Code

I was just trying to create a square that followed the mouse about, but as Y increases the shape gets taller and as x increases is gets wider

I'm expecting the bottom right of the shape to remain 100 pts (units, pixels?) away from the top left, but this isn't what's happening and I'm not too sure why.

Here's the code :

void setup() {

  size(500, 500);
  strokeWeight(7);
}

void draw() {
  background(255);
  rect(mouseX, mouseY, mouseX + 100, mouseY + 100);
}

Answers

Sign In or Register to comment.