@@ -199,8 +199,6 @@ var core = function (require, shim, constants) {
199199 f . call ( this ) ;
200200 } ) ;
201201 userDraw ( ) ;
202- this . _updatePMouseCoords ( ) ;
203- this . _updatePTouchCoords ( ) ;
204202 this . _registeredMethods . post . forEach ( function ( f ) {
205203 f . call ( this ) ;
206204 } ) ;
@@ -2956,6 +2954,7 @@ var inputmouse = function (require, core, constants) {
29562954 p5 . prototype . mouseIsPressed = false ;
29572955 p5 . prototype . isMousePressed = false ;
29582956 p5 . prototype . _updateMouseCoords = function ( e ) {
2957+ this . _updatePMouseCoords ( ) ;
29592958 if ( e . type === 'touchstart' || e . type === 'touchmove' ) {
29602959 this . _setProperty ( 'mouseX' , this . touchX ) ;
29612960 this . _setProperty ( 'mouseY' , this . touchY ) ;
@@ -3111,6 +3110,7 @@ var inputtouch = function (require, core) {
31113110 p5 . prototype . ptouchY = 0 ;
31123111 p5 . prototype . touches = [ ] ;
31133112 p5 . prototype . _updateTouchCoords = function ( e ) {
3113+ this . _updatePTouchCoords ( ) ;
31143114 if ( e . type === 'mousedown' || e . type === 'mousemove' ) {
31153115 this . _setProperty ( 'touchX' , this . mouseX ) ;
31163116 this . _setProperty ( 'touchY' , this . mouseY ) ;
@@ -3587,7 +3587,7 @@ var outputfiles = function (require, core) {
35873587 } else if ( args [ 0 ] instanceof p5 . Table ) {
35883588 p5 . prototype . saveTable ( args [ 0 ] , args [ 1 ] , args [ 2 ] , args [ 3 ] ) ;
35893589 } else if ( args [ 0 ] instanceof p5 . Image ) {
3590- p5 . prototype . saveCanvas ( args [ 0 ] . canvas , args [ 1 ] , args [ 2 ] ) ;
3590+ p5 . prototype . saveCanvas ( args [ 0 ] . canvas , args [ 1 ] ) ;
35913591 } else if ( args [ 0 ] instanceof p5 . SoundFile ) {
35923592 p5 . prototype . saveSound ( args [ 0 ] , args [ 1 ] , args [ 2 ] , args [ 3 ] ) ;
35933593 } else if ( args [ 0 ] instanceof Object ) {
@@ -3726,11 +3726,12 @@ var outputfiles = function (require, core) {
37263726 if ( ! extension ) {
37273727 extension = '' ;
37283728 }
3729+ if ( ! filename ) {
3730+ filename = 'untitled' ;
3731+ }
37293732 var ext = '' ;
3730- if ( filename ) {
3733+ if ( filename && filename . indexOf ( '.' ) > - 1 ) {
37313734 ext = filename . split ( '.' ) . pop ( ) ;
3732- } else {
3733- filename = 'untitled' ;
37343735 }
37353736 if ( extension ) {
37363737 if ( ext !== extension ) {
@@ -3743,6 +3744,7 @@ var outputfiles = function (require, core) {
37433744 ext
37443745 ] ;
37453746 }
3747+ p5 . prototype . _checkFileExtension = _checkFileExtension ;
37463748 p5 . prototype . _isSafari = function ( ) {
37473749 var x = Object . prototype . toString . call ( window . HTMLElement ) ;
37483750 return x . indexOf ( 'Constructor' ) > 0 ;
@@ -3757,6 +3759,12 @@ var outputimage = function (require, core) {
37573759 var p5 = core ;
37583760 var frames = [ ] ;
37593761 p5 . prototype . saveCanvas = function ( _cnv , filename , extension ) {
3762+ if ( ! extension ) {
3763+ extension = p5 . prototype . _checkFileExtension ( filename , extension ) [ 1 ] ;
3764+ if ( extension === '' ) {
3765+ extension = 'png' ;
3766+ }
3767+ }
37603768 var cnv ;
37613769 if ( _cnv ) {
37623770 cnv = _cnv ;
@@ -3772,7 +3780,7 @@ var outputimage = function (require, core) {
37723780 window . location . href = cnv . toDataURL ( ) ;
37733781 } else {
37743782 var mimeType ;
3775- if ( ! extension ) {
3783+ if ( typeof extension === 'undefined' ) {
37763784 extension = 'png' ;
37773785 mimeType = 'image/png' ;
37783786 } else {
0 commit comments