Removes the sketch from the web page.
Calling remove()
stops the draw loop and removes any HTML elements created by the sketch, including the canvas. A new sketch can be created by using the p5() constructor, as in new p5()
.
示例
// Double-click to remove the canvas.
function setup() {
createCanvas(100, 100);
describe(
'A white circle on a gray background. The circle follows the mouse as the user moves. The sketch disappears when the user double-clicks.'
);
}
function draw() {
// Paint the background repeatedly.
background(200);
// Draw circles repeatedly.
circle(mouseX, mouseY, 40);
}
// Remove the sketch when the user double-clicks.
function doubleClicked() {
remove();
}
Notice any errors or typos? Please let us know. Please feel free to edit src/core/main.js and open a pull request!