---
title: clearRect
framework: webkitjs
role: symbol
role_heading: Instance Method
path: webkitjs/canvasrenderingcontext2d/1632646-clearrect
---

# clearRect

Clears the specified rectangle to transparent black—RGBa(0,0,0,0).

## Declaration

```data
void clearRect(
    unrestricted float x, 
    unrestricted float y, 
    unrestricted float width, 
    unrestricted float height
);
```

## Parameters

- `x`: The x-coordinate of the left edge of the rectangle, in pixels from the left edge of the canvas coordinate system.
- `y`: The y-coordinate of the top of the rectangle, in pixels from the top of the canvas coordinate system.
- `width`: The width of the rectangle, in pixels.
- `height`: The height of the rectangle, in pixels.

## Discussion

Discussion All parameter values are in the canvas’s current coordinate system, subject to the current transformation matrix.

## See Also

### Drawing Rectangles

- [fillRect](webkitjs/canvasrenderingcontext2d/1633676-fillrect.md)
- [strokeRect](webkitjs/canvasrenderingcontext2d/1632379-strokerect.md)
