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

normalized red value.

g

normalized green value.

b

normalized blue value.

a

normalized alpha value.

Notice any errors or typos? Please let us know. Please feel free to edit src/color/setting.js and open a pull request!

Related References