File tree 2 files changed +7
-3
lines changed
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ class Engine {
25
25
this . _then = null ;
26
26
this . _is_recording = false ;
27
27
this . _first_frame_recorded = 0 ;
28
+ this . _frames_recorded = 0 ;
28
29
this . _zip = null ;
29
30
30
31
// start sketch
@@ -86,6 +87,8 @@ class Engine {
86
87
const data = this . _canvas . toDataURL ( "image/png" ) . split ( ";base64," ) [ 1 ] ;
87
88
// add frame to zip
88
89
this . _zip . file ( filename , data , { base64 : true } ) ;
90
+ // update the count of recorded frames
91
+ this . _frames_recorded ++ ;
89
92
}
90
93
91
94
// update frame count
@@ -116,6 +119,7 @@ class Engine {
116
119
startRecording ( ) {
117
120
this . _is_recording = true ;
118
121
this . _first_frame_recorded = this . _frameCount ;
122
+ this . _frames_recorded = 0 ;
119
123
this . _zip = new JSZip ( ) ;
120
124
}
121
125
@@ -134,7 +138,7 @@ class Engine {
134
138
saveRecording ( filename = "frames.zip" ) {
135
139
// if the recording is not active, do nothing
136
140
// 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 ;
138
142
139
143
// download zip file
140
144
this . _zip . generateAsync ( { type : "blob" } ) . then ( ( blob ) => {
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ class XOR128 {
119
119
* @param {Array } arr an array
120
120
*/
121
121
shuffle_array ( arr ) {
122
- arr
122
+ return arr
123
123
. map ( ( s ) => ( { sort : this . random ( ) , value : s } ) )
124
124
. sort ( ( a , b ) => a . sort - b . sort )
125
125
. map ( ( a ) => a . value ) ;
@@ -132,7 +132,7 @@ class XOR128 {
132
132
* @returns {String }
133
133
*/
134
134
shuffle_string ( string ) {
135
- string
135
+ return string
136
136
. split ( "" )
137
137
. map ( ( s ) => ( { sort : this . random ( ) , value : s } ) )
138
138
. sort ( ( a , b ) => a . sort - b . sort )
You can’t perform that action at this time.
0 commit comments