Clear a rectangle within a given rectangle:
JavaScript:
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.
The clearRect() method clears the specified pixels within a given rectangle.
JavaScript syntax: | context.clearRect(x,y,width,height); |
---|
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of the upper-left corner of the rectangle to clear | Play it » |
y | The y-coordinate of the upper-left corner of the rectangle to clear | Play it » |
width | The width of the rectangle to clear, in pixels | Play it » |
height | The height of the rectangle to clear, in pixels | Play it » |