The delay() method of p5.Image in p5.js is used to change the delay between each frame in a GIF animation. This value can be set in milliseconds and a higher value would mean that the GIF would show its next frame after a longer time.
An optional second parameter can be used to specify the index of the frame that needs to have the new delay value set. All the frames would get the new delay value if nothing is specified.
resize( d, index )
Parameters: This function accepts two parameters as mentioned above and described below.
- d: It is a number that specifies the amount to delay between each frame in milliseconds.
- index: It is a number that specifies the index of the frame that has to be modified. It is an optional parameter.
The examples below illustrate the delay() method in p5.js:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/