Name

CanvasRenderingContext2D.fillRect( ): fill a rectangle

Synopsis

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

Arguments

x, y

The coordinates of the upper-left corner of rectangle.

width, height

The dimensions of the rectangle.

Description

fillRect( ) fills the specified rectangle with the color, gradient, or pattern specified by the fillStyle property.

Current implementations of fillRect( ) also clear the path as if beginPath( ) had been called. This surprising behavior may not be standardized and should not be relied upon.

See Also

CanvasRenderingContext2D.fill( )
CanvasRenderingContext2D.rect( )
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.