Reference square()

square()

Draws a square.

A square is a four-sided shape defined by the x, y, and s parameters. x and y set the location of its top-left corner. s sets its width and height. Every angle in the square measures 90˚ and all its sides are the same length. See rectMode() for other ways to define squares.

The version of square() with four parameters creates a rounded square. The fourth parameter sets the radius for all four corners.

The version of square() with seven parameters also creates a rounded square. 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 square. If any of these parameters are omitted, they are set to the value of the last radius that was set.

Examples

Syntax

square(x, y, s, [tl], [tr], [br], [bl])

Parameters

x

x-coordinate of the square.

y

y-coordinate of the square.

s

side size of the square.

tl

optional radius of top-left corner.

tr

optional radius of top-right corner.

br

optional radius of bottom-right corner.

bl

optional radius of bottom-left corner.

Notice any errors or typos? Please let us know. Please feel free to edit src/core/shape/2d_primitives.js and open a pull request!

Related References