Easy Tutorial
❮ Tag Map Att Command Checked ❯

HTML canvas fill() Method

HTML canvas Reference Manual

Example

Draw a rectangle of 150*100 pixels and then fill it with red color:

JavaScript:


Browser Support

Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the fill() method.

Note: Internet Explorer 8 and earlier versions do not support the <canvas> element.


Definition and Usage

The fill() method fills the current image (path). The default color is black.

Tip: Use the fillStyle property to fill with another color/gradient.

Note: If the path is not closed, the fill() method adds a line from the end point to the start point to close the path (just like closePath()) and then fills the path.

| JavaScript Syntax: | context.fill(); | | --- | --- |


❮ Tag Map Att Command Checked ❯