Name

CanvasRenderingContext2D.clearRect( ): erase a rectangular area of a canvas

Synopsis

void clearRect(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

clearRect( ) erases the specified rectangle, filling it with a transparent color.

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.