From aa8d9a5121d9430561a14002507255d2a0d36899 Mon Sep 17 00:00:00 2001 From: ayushman1210 Date: Wed, 8 Oct 2025 22:04:50 +0530 Subject: [PATCH 1/6] fixed the bug of black-frames --- src/image/loading_displaying.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/image/loading_displaying.js b/src/image/loading_displaying.js index 3666ac1056..f7f9185462 100644 --- a/src/image/loading_displaying.js +++ b/src/image/loading_displaying.js @@ -256,7 +256,8 @@ function loadingDisplaying(p5, fn){ units: 'seconds', silent: false, notificationDuration: 0, - notificationID: 'progressBar' + notificationID: 'progressBar', + reset:true } ) { // validate parameters @@ -273,7 +274,7 @@ function loadingDisplaying(p5, fn){ const silent = (options && options.silent) || false; const notificationDuration = (options && options.notificationDuration) || 0; const notificationID = (options && options.notificationID) || 'progressBar'; - + const resetAnimation = (options && options.reset !== undefined) ? options.reset : true; // if arguments in the options object are not correct, cancel operation if (typeof delay !== 'number') { throw TypeError('Delay parameter must be a number'); @@ -324,11 +325,19 @@ function loadingDisplaying(p5, fn){ // that duration translates to const nFrames = units === 'seconds' ? duration * _frameRate : duration; const nFramesDelay = units === 'seconds' ? delay * _frameRate : delay; - const totalNumberOfFrames = nFrames + nFramesDelay; // initialize variables for the frames processing - let frameIterator = nFramesDelay; - this.frameCount = frameIterator; + let frameIterator; + let totalNumberOfFrames; + if (resetAnimation) { + frameIterator = nFramesDelay; + this.frameCount = frameIterator; + totalNumberOfFrames = nFrames + nFramesDelay; + } else { + frameIterator = this.frameCount + nFramesDelay; + totalNumberOfFrames = frameIterator + nFrames; + } + const lastPixelDensity = this._renderer._pixelDensity; this.pixelDensity(1); @@ -381,7 +390,7 @@ function loadingDisplaying(p5, fn){ to be drawn and immediately save it to a buffer and continue */ this.redraw(); - + await new Promise(resolve => requestAnimationFrame(resolve)); // depending on the context we'll extract the pixels one way // or another let data = undefined; From 7ddc2a016035ce5c12804e1ca08cdefa48da249c Mon Sep 17 00:00:00 2001 From: ayushman1210 Date: Wed, 15 Oct 2025 16:15:29 +0530 Subject: [PATCH 2/6] fixed the bug-frame as maintainer-suggested --- src/image/loading_displaying.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/loading_displaying.js b/src/image/loading_displaying.js index f7f9185462..914a538b3e 100644 --- a/src/image/loading_displaying.js +++ b/src/image/loading_displaying.js @@ -390,7 +390,7 @@ function loadingDisplaying(p5, fn){ to be drawn and immediately save it to a buffer and continue */ this.redraw(); - await new Promise(resolve => requestAnimationFrame(resolve)); + await new Promise(requestAnimationFrame); // depending on the context we'll extract the pixels one way // or another let data = undefined; From 89661af136af7359f0a49a0907cf51ff2b8a71b9 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 15 Oct 2025 17:33:41 +0530 Subject: [PATCH 3/6] Update src/image/loading_displaying.js --- src/image/loading_displaying.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/loading_displaying.js b/src/image/loading_displaying.js index 914a538b3e..8d0d312097 100644 --- a/src/image/loading_displaying.js +++ b/src/image/loading_displaying.js @@ -257,7 +257,7 @@ function loadingDisplaying(p5, fn){ silent: false, notificationDuration: 0, notificationID: 'progressBar', - reset:true + reset: true } ) { // validate parameters From 15f7908a830303229b9e9837426fab0e5493344b Mon Sep 17 00:00:00 2001 From: ayushman1210 Date: Wed, 15 Oct 2025 22:55:29 +0530 Subject: [PATCH 4/6] fixed the error at line 383 as maintainer-suggested --- src/image/loading_displaying.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/loading_displaying.js b/src/image/loading_displaying.js index 914a538b3e..277b639c37 100644 --- a/src/image/loading_displaying.js +++ b/src/image/loading_displaying.js @@ -380,7 +380,7 @@ function loadingDisplaying(p5, fn){ // // Waiting on this empty promise means we'll continue as soon as setup // finishes without waiting for another frame. - await Promise.resolve(); + await new Promise(requestAnimationFrame) while (frameIterator < totalNumberOfFrames) { /* From 1da6d858c4f3ecdd2d4a46288472efb9845a5b91 Mon Sep 17 00:00:00 2001 From: ayushman1210 Date: Wed, 15 Oct 2025 23:01:41 +0530 Subject: [PATCH 5/6] fixed the error at line 383 as maintainer-suggested --- src/image/loading_displaying.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/loading_displaying.js b/src/image/loading_displaying.js index 277b639c37..e04a3a259e 100644 --- a/src/image/loading_displaying.js +++ b/src/image/loading_displaying.js @@ -257,7 +257,7 @@ function loadingDisplaying(p5, fn){ silent: false, notificationDuration: 0, notificationID: 'progressBar', - reset:true + reset: true } ) { // validate parameters From 7dbc74a3e3d09b9dfcea85c04fa100e5f0603b1e Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:34:23 +0530 Subject: [PATCH 6/6] Fix formatting and spacing in loading_displaying.js --- src/image/loading_displaying.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/image/loading_displaying.js b/src/image/loading_displaying.js index e04a3a259e..83af0b0b1d 100644 --- a/src/image/loading_displaying.js +++ b/src/image/loading_displaying.js @@ -327,8 +327,9 @@ function loadingDisplaying(p5, fn){ const nFramesDelay = units === 'seconds' ? delay * _frameRate : delay; // initialize variables for the frames processing - let frameIterator; + let frameIterator; let totalNumberOfFrames; + if (resetAnimation) { frameIterator = nFramesDelay; this.frameCount = frameIterator; @@ -338,7 +339,6 @@ function loadingDisplaying(p5, fn){ totalNumberOfFrames = frameIterator + nFrames; } - const lastPixelDensity = this._renderer._pixelDensity; this.pixelDensity(1); @@ -390,7 +390,7 @@ function loadingDisplaying(p5, fn){ to be drawn and immediately save it to a buffer and continue */ this.redraw(); - await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); // depending on the context we'll extract the pixels one way // or another let data = undefined;