Draws a rectangle.
A rectangle is a four-sided shape defined by the x
, y
, w
, and h
parameters. x
and y
set the location of its top-left corner. w
sets its width and h
sets its height. Every angle in the rectangle measures 90˚. See rectMode() for other ways to define rectangles.
The version of rect()
with five parameters creates a rounded rectangle. The fifth parameter sets the radius for all four corners.
The version of rect()
with eight parameters also creates a rounded rectangle. Each of the last four parameters set the radius of a corner. The radii start with the top-left corner and move clockwise around the rectangle. If any of these parameters are omitted, they are set to the value of the last radius that was set.
Examples
Syntax
rect(x, y, w, [h], [tl], [tr], [br], [bl])
rect(x, y, w, h, [detailX], [detailY])