Skip to content
Open
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
20 changes: 11 additions & 9 deletions src/image/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,15 @@ function loadingDisplaying(p5, fn){
const nFramesDelay = units === 'seconds' ? delay * _frameRate : delay;

// initialize variables for the frames processing
let frameIterator;
let totalNumberOfFrames;
// frameIterator starts at 0 so the first nFramesDelay frames are
// rendered as un-captured warmup before recording begins
let frameIterator = 0;
const totalNumberOfFrames = nFrames + nFramesDelay;

if (resetAnimation) {
frameIterator = nFramesDelay;
this.frameCount = frameIterator;
totalNumberOfFrames = nFrames + nFramesDelay;
} else {
frameIterator = this.frameCount + nFramesDelay;
totalNumberOfFrames = frameIterator + nFrames;
// restart the animation from the beginning so the gif
// captures the first frames of the animation
this.frameCount = 0;
}

const lastPixelDensity = this._renderer._pixelDensity;
Expand Down Expand Up @@ -415,7 +414,10 @@ function loadingDisplaying(p5, fn){
.data;
}

frames.push(data);
// only capture frames once the delay/warmup phase has passed
if (frameIterator >= nFramesDelay) {
frames.push(data);
}
frameIterator++;

if (!silent) {
Expand Down