fixed background settings not applying ( save )
This commit is contained in:
parent
dac9aaada9
commit
6a47a2ff9d
@ -23,27 +23,18 @@ $('a[href^="http"]').on('tap', function(e) {
|
|||||||
window.save = function() {
|
window.save = function() {
|
||||||
switch(save.background) {
|
switch(save.background) {
|
||||||
case 'white': {
|
case 'white': {
|
||||||
var cache = {
|
|
||||||
fillStyle: c.color,
|
|
||||||
composite: c.globalCompositeOperation
|
|
||||||
}
|
|
||||||
c.fillStyle = 'white';
|
c.fillStyle = 'white';
|
||||||
c.globalCompositeOperation = 'destination-over';
|
c.globalCompositeOperation = 'destination-over';
|
||||||
c.fillRect(0, 0, width(), height());
|
c.fillRect(0, 0, width(), height());
|
||||||
c.fillStyle = cache.fillStyle;
|
c.fillStyle = settings.color;
|
||||||
c.globalCompositeOperation = cache.composite;
|
c.globalCompositeOperation = settings.composite;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'current color': {
|
case 'current color': {
|
||||||
var cache = {
|
|
||||||
fillStyle: c.color,
|
|
||||||
composite: c.globalCompositeOperation
|
|
||||||
}
|
|
||||||
c.fillStyle = settings.strokeStyle;
|
c.fillStyle = settings.strokeStyle;
|
||||||
c.globalCompositeOperation = 'destination-over';
|
c.globalCompositeOperation = 'destination-over';
|
||||||
c.fillRect(0, 0, width(), height());
|
c.fillRect(0, 0, width(), height());
|
||||||
c.fillStyle = cache.fillStyle;
|
c.globalCompositeOperation = settings.composite;
|
||||||
c.globalCompositeOperation = cache.composite;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ Changelog
|
|||||||
* No load-time for Mobile
|
* No load-time for Mobile
|
||||||
* Added preloader for images
|
* Added preloader for images
|
||||||
* Fixed low lineWidth for sketches rendering invisible in Chrome
|
* Fixed low lineWidth for sketches rendering invisible in Chrome
|
||||||
|
* Fixed background settings not applying ( save )
|
||||||
|
|
||||||
License
|
License
|
||||||
=======
|
=======
|
||||||
|
@ -138,10 +138,6 @@
|
|||||||
<li><label><span>Current Color</span></label></li>
|
<li><label><span>Current Color</span></label></li>
|
||||||
<li><label><span>Transparent</span></label></li>
|
<li><label><span>Transparent</span></label></li>
|
||||||
</ol>
|
</ol>
|
||||||
<h1>File Name</h1>
|
|
||||||
<ol role='listbox'>
|
|
||||||
<li aria-selected='true' data-input><label><span contenteditable>My Sketch</span></label></li>
|
|
||||||
</ol>
|
|
||||||
<br>
|
<br>
|
||||||
<span>Note: You must disable pop-up blocker to save your sketch.</span>
|
<span>Note: You must disable pop-up blocker to save your sketch.</span>
|
||||||
</section>
|
</section>
|
||||||
|
@ -5,36 +5,29 @@ $(window).resize(sizeAndPos);
|
|||||||
// Check for update
|
// Check for update
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
|
var cData = c.getImageData(0, 0, width(), height());
|
||||||
switch(save.background) {
|
switch(save.background) {
|
||||||
case 'white': {
|
case 'white': {
|
||||||
var cache = {
|
|
||||||
color: c.color,
|
|
||||||
composite: c.globalCompositeOperation
|
|
||||||
}
|
|
||||||
c.fillStyle = 'white';
|
c.fillStyle = 'white';
|
||||||
c.globalCompositeOperation = 'destination-over';
|
c.globalCompositeOperation = 'destination-over';
|
||||||
c.fillRect(0, 0, width(), height());
|
c.fillRect(0, 0, width(), height());
|
||||||
c.fillStyle = cache.fillStyle;
|
c.fillStyle = settings.color;
|
||||||
c.globalCompositeOperation = cache.composite;
|
c.globalCompositeOperation = settings.composite;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'current color': {
|
case 'current color': {
|
||||||
var cache = {
|
|
||||||
fillStyle: c.color,
|
|
||||||
composite: c.globalCompositeOperation
|
|
||||||
}
|
|
||||||
c.fillStyle = settings.strokeStyle;
|
c.fillStyle = settings.strokeStyle;
|
||||||
c.globalCompositeOperation = 'destination-over';
|
c.globalCompositeOperation = 'destination-over';
|
||||||
c.fillRect(0, 0, width(), height());
|
c.fillRect(0, 0, width(), height());
|
||||||
c.fillStyle = cache.fillStyle;
|
c.fillStyle = settings.color;
|
||||||
c.globalCompositeOperation = cache.composite;
|
c.globalCompositeOperation = settings.composite;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var data = $c[0].toDataURL();
|
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) {
|
$(this).parents('form').find('h1').each(function(i) {
|
||||||
if( i > 0 ) {
|
if( i > 0 ) {
|
||||||
var key = $(this).html().toLowerCase();
|
var key = $(this).html().toLowerCase();
|
||||||
var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html();
|
var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html().toLowerCase();
|
||||||
if( key !== 'file name' ) value = key.toLowerCase();
|
|
||||||
|
|
||||||
window[v][key] = value;
|
window[v][key] = value;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -21,10 +21,11 @@ $('a[href^="http"]').on('tap', function(e) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
|
var cData = c.getImageData(0, 0, width(), height());
|
||||||
switch(save.background) {
|
switch(save.background) {
|
||||||
case 'white': {
|
case 'white': {
|
||||||
var cache = {
|
var cache = {
|
||||||
fillStyle: c.color,
|
color: c.color,
|
||||||
composite: c.globalCompositeOperation
|
composite: c.globalCompositeOperation
|
||||||
}
|
}
|
||||||
c.fillStyle = 'white';
|
c.fillStyle = 'white';
|
||||||
@ -48,17 +49,10 @@ function save() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var data = $c[0].toDataURL();
|
var data = $c[0].toDataURL();
|
||||||
var file = dataToBlob($c[0].toDataURL());
|
window.open(data, '_blank').focus();
|
||||||
var pics = navigator.getDeviceStorage('pictures');
|
|
||||||
var r = pics.addNamed(file, save['file name'] + '.png');
|
c.putImageData(cData, 0, 0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.menu').tap(function() {
|
$('.menu').tap(function() {
|
||||||
@ -134,9 +128,7 @@ function save() {
|
|||||||
$(this).parents('form').find('h1').each(function(i) {
|
$(this).parents('form').find('h1').each(function(i) {
|
||||||
if( i > 0 ) {
|
if( i > 0 ) {
|
||||||
var key = $(this).html().toLowerCase();
|
var key = $(this).html().toLowerCase();
|
||||||
var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html();
|
var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html().toLowerCase();
|
||||||
if( key !== 'file name' ) value = value.toLowerCase();
|
|
||||||
|
|
||||||
window[v][key] = value;
|
window[v][key] = value;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
<li>No Load-time for mobile</li>
|
<li>No Load-time for mobile</li>
|
||||||
<li>Added preloader for images</li>
|
<li>Added preloader for images</li>
|
||||||
<li>Fixed low lineWidth for sketches rendering invisible in Chrome</li>
|
<li>Fixed low lineWidth for sketches rendering invisible in Chrome</li>
|
||||||
|
<li>Fixed background settings not applying ( save )</li>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user