Name

CanvasRenderingContext2D.rect( ): add a rectangle subpath to the path

Synopsis

void rect(floatx, float y,
          float width, float height)

Arguments

x, y

The coordinates of the upper-left corner of the rectangle.

width, height

The dimensions of the rectangle.

Description

This method adds a rectangle to the path. This rectangle is in a subpath of its own and is not connected to any other subpaths in the path. When this method returns, the current position is (0,0).

See Also

CanvasRenderingContext2D.fillRect( ), CanvasRenderingContext2D.strokeRect( )

Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.