Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

clearRect method

Clears the pixels on a CanvasRenderingContext2D object within a given rectangle.

HTML Canvas 2D Context, Section 8Internet Explorer 9

 

Syntax


object.clearRect(x, y, w, h);

Parameters

x [in]

Type: number

The x-coordinate, in pixels, of the upper-left corner of the rectangle in relation to the coordinates of the canvas.

y [in]

Type: number

The x-coordinate, in pixels, of the upper-left corner of the rectangle in relation to the coordinates of the canvas.

w [in]

Type: number

The width, in pixels, of the rectangle in relation to the coordinates of the canvas.

h [in]

Type: number

The height, in pixels, of the rectangle in relation to the coordinates of the canvas.

Return value

This method does not return a value.

Standards information

Remarks

The ICanvasRenderingContext2D::clearRect method clears the canvas to transparent black (that is, each pixel's RGBA value is equal to zero). To clear to a specific color, use the ICanvasRenderingContext2D::fillRect method.

See also

ICanvasRenderingContext2D::fillRect

 

 

Community Additions

ADD
Show:
© 2015 Microsoft