---
title: fillRect
framework: webkitjs
role: symbol
role_heading: Instance Method
path: webkitjs/canvasrenderingcontext2d/1633676-fillrect
---

# fillRect

Fills a specified rectangle in the current fill color, gradient, or pattern.

## Declaration

```data
void fillRect(
    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 edge 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 (rotation, scale, and so on).

## See Also

### Drawing Rectangles

- [clearRect](webkitjs/canvasrenderingcontext2d/1632646-clearrect.md)
- [strokeRect](webkitjs/canvasrenderingcontext2d/1632379-strokerect.md)
