Reference clear()

clear()

Clears the pixels on the canvas.

clear() makes every pixel 100% transparent. Calling clear() doesn't clear objects created by createX() functions such as createGraphics(), createVideo(), and createImg(). These objects will remain unchanged after calling clear() and can be redrawn.

In WebGL mode, this function can clear the screen to a specific color. It interprets four numeric parameters as normalized RGBA color values. It also clears the depth buffer. If you are not using the WebGL renderer, these parameters will have no effect.

Examples

Syntax

clear([r], [g], [b], [a])

Parameters

r
Number:

normalized red value.

g
Number:

normalized green value.

b
Number:

normalized blue value.

a
Number:

normalized alpha value.

This page is generated from the comments in src/color/setting.js . Please feel free to edit it and submit a pull request!

Related References