rect() - Version: 230

Example

void setup(){

fill(0,0,255); //fill the rectangle with a blue color
stroke(255, 255, 255); //make the outline a white color

rect(20,20,80,80); //draw the rectangle

}

void loop() {

}

Description

Draws a rectangle to the screen. A rectangle is a four-sided shape with every angle at ninety degrees. The first two parameters set the location, the third sets the width, and the fourth sets the height.

Syntax


rect(x, y, width, height)


Parameters

x – x-coordinate of the rectangle

y – y-coordinate of the rectangle

width – width of the rectangle

height – height of the rectangle

Returns

none

Related

none

Bugs

By: Mike Gionfriddo on 12/23/2008
1) When I make a small square, it doesn’t draw it properly
2) When I draw a rectangle that goes off the screen it doesn’t execute the color fill function.




Edit History