Easy Tutorial
❮ Att Select Required Av Event Timeupdate ❯

HTML canvas strokeRect() Method

HTML canvas Reference Manual

Example

Draw a rectangle with dimensions 150*100 pixels:

JavaScript:


Browser Support

Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the strokeRect() method.

Note: Internet Explorer 8 and earlier versions do not support the <canvas> element.


Definition and Usage

The strokeRect() method draws a rectangle (no fill). The default stroke color is black.

Tip: Use the strokeStyle property to set the stroke color, gradient, or pattern.

| JavaScript Syntax: | context.strokeRect(x, y, width, height); | | --- | --- |

Parameter Values

Parameter Description
x The x-coordinate of the top-left corner of the rectangle.
y The y-coordinate of the top-left corner of the rectangle.
width The width of the rectangle, in pixels.
height The height of the rectangle, in pixels.
❮ Att Select Required Av Event Timeupdate ❯