Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/image/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ p5.prototype.saveGif = async function(
if (typeof duration !== 'number') {
throw TypeError('Duration parameter must be a number');
}
if (duration <= 0) {
return;
}

// extract variables for more comfortable use
const delay = (options && options.delay) || 0; // in seconds
Expand Down
9 changes: 9 additions & 0 deletions test/unit/image/downloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ suite('p5.prototype.saveGif', function() {
});
});

test('should silently return if duration is less than or equal to 0', function() {
assert.doesNotThrow(function() {
myp5.saveGif('myGif', 0);
});
assert.doesNotThrow(function() {
myp5.saveGif('myGif', -5);
});
});

testWithDownload('should download a GIF', async function(blobContainer) {
myp5.saveGif(myGif, 3, 2);
await waitForBlob(blobContainer);
Expand Down