Canvas

Canvas Tutorials

Canvas Methods and Properties

HTML canvas rect() Method

HTML canvas rect() Method

 

 

The rect() method creates a rectangle. It is used in combination with the stroke() and fill() method to actually draw it on canvas.

 

Syntax:-

 

Its syntax is:- context.rect(x, y, width, height);

 

Further Explanation:-

 

Parameter Description
x The x-coordinate of the upper-left corner of the rectangle
y The y-coordinate of the upper-left corner of the rectangle
width The width of the rectangle, in pixels
height The height of the rectangle, in pixels

Code Explanation

All Tutorials related to Canvas Methods and Properties

All Sections related to Canvas