We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to create a kind of cube/cuboid with two rectangles. I want to know how to join two corresponding corners of two different rectangles using a line. Is there a way to reference the location of each corner of a rectangle?
Answers
a rect is given by
rect(x,y,w,h);
(x and y position and width and height)so when you draw a rect this way you already have all necessary data:
your first corner is x,y
diagonal corner is x+w, y+h
lower left corner is x, y+h (only y value changes)
upper right corner is x+w, y (only x value changes)
;-)
That is a good way to do it. Thanks Chrisir.
Great!
when you write a
class Rectangle
you can make this more elegant when you usePVector
likeupperLeftCorner
upperRightCorner
lowerLeftCorner
lowerRightCorner
We can also change rectMode() to CORNERS:
https://processing.org/reference/rectMode_.html