Skip to content
Related Articles
Open in App
Not now

Related Articles

p5.Image reset() Method

Improve Article
Save Article
Like Article
  • Last Updated : 18 Sep, 2020
Improve Article
Save Article
Like Article

The reset() method of p5.Image in p5.js is used to restart an animated GIF and play it from its beginning state. It can be used with a button press or user input to restart the GIF animation. It does not accept any parameters.



Parameters: This method does not accept any parameter.

The example below illustrates the reset() method in p5.js:



function preload() {
    example_gif = loadImage("sample-gif.gif");
function setup() {
    createCanvas(500, 300);
    text("Click on the button to " +
         "reset the animation", 20, 20);
    resetBtn = 
      createButton("Reset Animation");
    resetBtn.position(30, 40);
function draw() {
    image(example_gif, 20, 60, 300, 200);
function resetAnimation() {
    // Reset the animation using
    // the reset() method


Online editor:
Environment Setup:

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!