192k views
3 votes
To clear a drawing space for each callback of draw() method, you call the method

User Colibri
by
8.3k points

1 Answer

2 votes

Final answer:

To clear a drawing space for each callback of the draw() method, you call the clear() function.

Step-by-step explanation:

To clear a drawing space for each callback of the draw() method in p5.js, you can call the clear() function. This function clears the entire canvas, allowing you to start fresh with each frame. Here's an example:

function setup() {
createCanvas(400, 400);
}

function draw() {
clear();
// draw your new frame here
}

User Simmone
by
7.2k points