Easy Tutorial
❮ Att Global Accesskey Tag Blockquote ❯

HTML canvas clearRect() Method

HTML canvas Reference Manual

Example

Clears a rectangle within a given rectangle:

JavaScript:


Browser Support

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

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


Definition and Usage

The clearRect() method clears the specified pixels within a given rectangle.

| JavaScript Syntax: | context.clearRect(x, y, width, height); | | --- | --- |

Parameter Values

Parameter Description
x The x-coordinate of the top-left corner of the rectangle to clear.
y The y-coordinate of the top-left corner of the rectangle to clear.
width The width of the rectangle to clear, in pixels.
height The height of the rectangle to clear, in pixels.
❮ Att Global Accesskey Tag Blockquote ❯