Friday, October 24, 2025
HomeLanguagesJavascriptp5.js noErase() Function

p5.js noErase() Function

The noErase() function in p5.js is used to cancel the effects of the erase() function. It will return the functionality of the fill(), stroke(), and blendMode() functions to what they were before using erase(). Any drawing done after this function would be drawn normally.

Syntax:

noErase()

Parameters: This function does not accept any parameters.

Below example illustrates the noErase() function in p5.js:

Example:




function setup() {
    createCanvas(600, 400);
    textSize(20);
    firstBlockSlider = createSlider(50, 250, 75, 1);
    firstBlockSlider.position(30, 50);
   
    secondBlockSlider = createSlider(50, 250, 175, 1);
    secondBlockSlider.position(30, 120);
}
   
function draw() {
    clear();
    fill('black');
    text("Move the slider below to change the"
        + " first block's position", 20, 30);
    text("Move the slider below to change the"
        + " second block's position", 20, 100);
    text("The black circle demonstrates the"
        + " erase area", 20, 170);
   
    fill('red');
    rect(firstBlockSlider.value(), 200, 50, 100);
   
    // Start erasing with erase()
    erase();
    circle(150, 250, 100);
   
    // Stop erasing with noErase()
    noErase();
   
    fill('red');
    rect(secondBlockSlider.value(), 200, 50, 100);
   
    // Circle to illustrate the erase position
    noFill();
    circle(150, 250, 100);
}


Output:
demonstrate-noerase

Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/

Reference: https://p5js.org/reference/#/p5/noErase

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS