---
title: strokeRect
framework: webkitjs
role: symbol
role_heading: Instance Method
path: webkitjs/canvasrenderingcontext2d/1632379-strokerect
---

# strokeRect

Draws a rectangle using the current stroke color, pattern, or gradient.

## Declaration

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

## Parameters

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

## 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)
- [fillRect](webkitjs/canvasrenderingcontext2d/1633676-fillrect.md)
