rectMode()
changes the way a rectangle is drawn from the inputs
Last updated
changes the way a rectangle is drawn from the inputs
Last updated
By default, the x and y inputs refer to the bottom left corner of the rectangle.
This can be changed using rectMode()
, with an input of CORNER, CORNERS, RADIUS or CENTER.
This is the default mode. The code:
will use (x,y) as the bottom left corner coordinates and width and height as the dimensions.
This mode is for specifying the coordinates of opposite corners. The code:
will use (x1,y1) as the bottom left corner coordinates and (x2,y2) as the top right (diagonally opposite) corner coordinates.
This mode is for specifying the center of the rectangle together with the width and height. The code:
will use (x,y) as the center coordinates and width and height as the dimensions.
This mode is for specifying the center of the rectangle together with half the width and half the height. The code:
See rect() for examples and more info.
Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!
We'd love to hear your Feedback/Comments here.