Skip to content

Commit 9d786cd

Browse files
committed
fixes
1 parent 567eab1 commit 9d786cd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

js/engine.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Engine {
2525
this._then = null;
2626
this._is_recording = false;
2727
this._first_frame_recorded = 0;
28+
this._frames_recorded = 0;
2829
this._zip = null;
2930

3031
// start sketch
@@ -86,6 +87,8 @@ class Engine {
8687
const data = this._canvas.toDataURL("image/png").split(";base64,")[1];
8788
// add frame to zip
8889
this._zip.file(filename, data, { base64: true });
90+
// update the count of recorded frames
91+
this._frames_recorded++;
8992
}
9093

9194
// update frame count
@@ -116,6 +119,7 @@ class Engine {
116119
startRecording() {
117120
this._is_recording = true;
118121
this._first_frame_recorded = this._frameCount;
122+
this._frames_recorded = 0;
119123
this._zip = new JSZip();
120124
}
121125

@@ -134,7 +138,7 @@ class Engine {
134138
saveRecording(filename = "frames.zip") {
135139
// if the recording is not active, do nothing
136140
// also skipped if no frame has been recorded
137-
if (this._is_recording || !this._zip) return;
141+
if (this._is_recording || !this._zip || this._frames_recorded == 0) return;
138142

139143
// download zip file
140144
this._zip.generateAsync({ type: "blob" }).then((blob) => {

js/xor128.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class XOR128 {
119119
* @param {Array} arr an array
120120
*/
121121
shuffle_array(arr) {
122-
arr
122+
return arr
123123
.map((s) => ({ sort: this.random(), value: s }))
124124
.sort((a, b) => a.sort - b.sort)
125125
.map((a) => a.value);
@@ -132,7 +132,7 @@ class XOR128 {
132132
* @returns {String}
133133
*/
134134
shuffle_string(string) {
135-
string
135+
return string
136136
.split("")
137137
.map((s) => ({ sort: this.random(), value: s }))
138138
.sort((a, b) => a.sort - b.sort)

0 commit comments

Comments
 (0)