diff --git a/Mobile/js/mobile.js b/Mobile/js/mobile.js index 7d883ef..dc3f3a1 100644 --- a/Mobile/js/mobile.js +++ b/Mobile/js/mobile.js @@ -23,27 +23,18 @@ $('a[href^="http"]').on('tap', function(e) { window.save = function() { switch(save.background) { case 'white': { - var cache = { - fillStyle: c.color, - composite: c.globalCompositeOperation - } c.fillStyle = 'white'; c.globalCompositeOperation = 'destination-over'; c.fillRect(0, 0, width(), height()); - c.fillStyle = cache.fillStyle; - c.globalCompositeOperation = cache.composite; + c.fillStyle = settings.color; + c.globalCompositeOperation = settings.composite; break; } case 'current color': { - var cache = { - fillStyle: c.color, - composite: c.globalCompositeOperation - } c.fillStyle = settings.strokeStyle; c.globalCompositeOperation = 'destination-over'; c.fillRect(0, 0, width(), height()); - c.fillStyle = cache.fillStyle; - c.globalCompositeOperation = cache.composite; + c.globalCompositeOperation = settings.composite; break; } } diff --git a/README.md b/README.md index bea70b1..d01b813 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Changelog * No load-time for Mobile * Added preloader for images * Fixed low lineWidth for sketches rendering invisible in Chrome +* Fixed background settings not applying ( save ) License ======= diff --git a/Web/index.html b/Web/index.html index 525f339..127de7d 100644 --- a/Web/index.html +++ b/Web/index.html @@ -138,10 +138,6 @@
  • -

    File Name

    -
      -
    1. -

    Note: You must disable pop-up blocker to save your sketch. diff --git a/Web/js/desktop.js b/Web/js/desktop.js index 09d5994..c9fe5aa 100644 --- a/Web/js/desktop.js +++ b/Web/js/desktop.js @@ -5,36 +5,29 @@ $(window).resize(sizeAndPos); // Check for update function save() { + var cData = c.getImageData(0, 0, width(), height()); switch(save.background) { case 'white': { - var cache = { - color: c.color, - composite: c.globalCompositeOperation - } c.fillStyle = 'white'; c.globalCompositeOperation = 'destination-over'; c.fillRect(0, 0, width(), height()); - c.fillStyle = cache.fillStyle; - c.globalCompositeOperation = cache.composite; + c.fillStyle = settings.color; + c.globalCompositeOperation = settings.composite; break; } case 'current color': { - var cache = { - fillStyle: c.color, - composite: c.globalCompositeOperation - } c.fillStyle = settings.strokeStyle; c.globalCompositeOperation = 'destination-over'; c.fillRect(0, 0, width(), height()); - c.fillStyle = cache.fillStyle; - c.globalCompositeOperation = cache.composite; + c.fillStyle = settings.color; + c.globalCompositeOperation = settings.composite; break; } } var data = $c[0].toDataURL(); - window.open(data, save['file name']).focus(); + window.open(data, '_blank').focus(); - c.putImageData(window.points.history[window.points.history.length-1].data, 0, 0); + c.putImageData(cData, 0, 0); } @@ -109,9 +102,7 @@ function save() { $(this).parents('form').find('h1').each(function(i) { if( i > 0 ) { var key = $(this).html().toLowerCase(); - var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html(); - if( key !== 'file name' ) value = key.toLowerCase(); - + var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html().toLowerCase(); window[v][key] = value; } }) diff --git a/Web/js/mobile.js b/Web/js/mobile.js index c0c1ed8..dcb0fa5 100644 --- a/Web/js/mobile.js +++ b/Web/js/mobile.js @@ -21,10 +21,11 @@ $('a[href^="http"]').on('tap', function(e) { }) function save() { + var cData = c.getImageData(0, 0, width(), height()); switch(save.background) { case 'white': { var cache = { - fillStyle: c.color, + color: c.color, composite: c.globalCompositeOperation } c.fillStyle = 'white'; @@ -47,18 +48,11 @@ function save() { break; } } - var data = $c[0].toDataURL(); - var file = dataToBlob($c[0].toDataURL()); - var pics = navigator.getDeviceStorage('pictures'); - var r = pics.addNamed(file, save['file name'] + '.png'); - r.onsuccess = function() { - alert('Your sketch was successfuly saved to ' + this.result); - } - r.onerror = function() { - alert('Something bad happened when we tried to save your file\n Possible problems: \n Duplicate name \n Permission problems') - console.warn(this.error); - } - c.putImageData(window.points.history[window.points.history.last].data, 0, 0); + var data = $c[0].toDataURL(); + window.open(data, '_blank').focus(); + + c.putImageData(cData, 0, 0); + } $('.menu').tap(function() { @@ -134,9 +128,7 @@ function save() { $(this).parents('form').find('h1').each(function(i) { if( i > 0 ) { var key = $(this).html().toLowerCase(); - var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html(); - if( key !== 'file name' ) value = value.toLowerCase(); - + var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html().toLowerCase(); window[v][key] = value; } }) diff --git a/changelog.html b/changelog.html index 5e1a15c..68cbbcd 100644 --- a/changelog.html +++ b/changelog.html @@ -9,6 +9,7 @@
  • No Load-time for mobile
  • Added preloader for images
  • Fixed low lineWidth for sketches rendering invisible in Chrome
  • +
  • Fixed background settings not applying ( save )