Draws a rectangle on the canvas. A rectangle is a four-sided closed 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 may be changed with
The fifth, sixth, seventh and eighth parameters, if specified, determine corner radius for the top-left, top-right, lower-right and lower-left corners, respectively. An omitted corner radius parameter is set to the value of the previously specified radius value in the parameter list.
from proceso import Sketch p5 = Sketch() p5.describe("White rect with black outline in mid-right of canvas") # Draw a rectangle at location (30, 20) with a width and height of 55. p5.rect(30, 20, 55, 55)
from proceso import Sketch p5 = Sketch() p5.describe( "White rectangle with black outline and round edges in mid-right of canvas" ) # Draw a rectangle with rounded corners, each having a radius of 20. p5.rect(30, 20, 55, 55, 20)
from proceso import Sketch p5 = Sketch() p5.describe( "White rectangle with black outline and round edges of different radii" ) # Draw a rectangle with rounded corners having the following radii: # top-left = 20, top-right = 15, bottom-right = 10, bottom-left = 5. p5.rect(30, 20, 55, 55, 20, 15, 10, 5)
rect(x, y, w, [h], [tl], [tr], [br], [bl])
rect(x, y, w, h, [detail_x], [detail_y])
x: float x-coordinate of the rectangle.
y: float y-coordinate of the rectangle.
w: float Width of the rectangle.
h: float Height of the rectangle.
[tl]: float Radius of top-left corner.
[tr]: float Radius of top-right corner.
[br]: float Radius of bottom-right corner.
[bl]: float Radius of bottom-left corner.
[detail_x]: int Number of segments in the x-direction (for WebGL mode).
[detail_y]: int Number of segments in the y-direction (for WebGL mode).