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.
示例
语法
square(x, y, s, [tl], [tr], [br], [bl])
参数
x-coordinate of the square.
y-coordinate of the square.
side size of the square.
optional radius of top-left corner.
optional radius of top-right corner.
optional radius of bottom-right corner.
optional radius of bottom-left corner.