Canvas

Canvas Tutorials

Canvas Methods and Properties

HTML canvas fillRect() Method

HTML canvas fillRect() Method

 

 

The fillRect() method is used to draw a filled rectangle. We can change its color by fillStyle.

 

Default Value:-

 

The default color of the fill is black.

 

Syntax:-

 

Its syntax is:- context.fillRect(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