Why is it that I have to use (100,40,400,210) to make the rectangle the same size as the lines? I would have thought I could use (100,40,500,250). It doesn’t make sense to me that 400, 210 is at the same spot as where my line ends but it is at 500, 250.
The reason is this
Line works with x1,y1 and x2,y2
rect works with x,y and w,h
Hence the difference
Oh I understand now. Thank you!
You can use the rectMode function to change how the parameters are interpreted, for instance rectMode(CORNERS) works with x1,y1 and x2,y2
void setup(){
size(640, 480);
}
void draw(){
background(200);
rectMode(CORNERS);
noStroke();
fill(128,128,255);
rect(100, 40, 500, 250);
stroke(0);
strokeWeight(5);
line(100, 40, 500, 250);
strokeWeight(3);
line(500,40,100,250);
}
gives you
Thank you! I see how that works now. I’m literally just starting as you can tell. ![]()
Every expert starts as a novice, enjoy the journey ![]()

