Easy Tutorial
❮ Prop Label Form Prop Option Text ❯

HTML canvas clearRect() Method

Canvas Object

Example

Clears a rectangle within the 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.
❮ Prop Label Form Prop Option Text ❯