Name
rect()
Description
Draws a rectangle to the screen. A rectangle is a four-sided shape with every
angle at ninety degrees. By default, the first two parameters set the
location of the upper-left corner, the third sets the width, and the fourth
sets the height. The way these parameters are interpreted, however, may be
changed with the rectMode() function.
To draw a rounded rectangle, add a fifth parameter, which is used as the
radius value for all four corners.
To use a different radius value for each corner, include eight parameters.
When using eight parameters, the latter four set the radius of the arc at
each corner separately, starting with the top-left corner and moving
clockwise around the rectangle.
Examples
size(400, 400); rect(120, 80, 220, 220);![Image output for example 1]()
size(400, 400); rect(120, 80, 220, 220, 28);![Image output for example 2]()
size(400, 400); rect(120, 80, 220, 220, 12, 24, 48, 72);![Image output for example 3]()
Syntax
rect(a, b, c, d)rect(a, b, c, d, r)rect(a, b, c, d, tl, tr, br, bl)
Parameters
a(float)x-coordinate of the rectangle by defaultb(float)y-coordinate of the rectangle by defaultc(float)width of the rectangle by defaultd(float)height of the rectangle by defaultr(float)radii for all four cornerstl(float)radius for top-left cornertr(float)radius for top-right cornerbr(float)radius for bottom-right cornerbl(float)radius for bottom-left corner
Return
void
Related

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


