v1.5.24 - smarter generation

This commit is contained in:
Azgaar 2021-02-13 21:52:50 +03:00
parent e4e40fab49
commit 2f3f5d05fb
4 changed files with 17 additions and 24 deletions

View file

@ -257,13 +257,13 @@ function editEmblem(type, id, el) {
const img = new Image();
img.src = url;
img.onload = async function() {
img.onload = function() {
if (format === "jpeg") {
ctx.fillStyle = "#fff";
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
const URL = await canvas.toDataURL("image/" + format, .92);
const URL = canvas.toDataURL("image/" + format, .92);
link.href = URL;
link.click();
window.setTimeout(() => window.URL.revokeObjectURL(URL), 5000);
@ -277,12 +277,10 @@ function editEmblem(type, id, el) {
return url;
}
function getSVG(svg, coa, size) {
function getSVG(svg, size) {
const clone = svg.cloneNode(true); // clone svg
clone.setAttribute("width", size);
clone.setAttribute("height", size);
return (new XMLSerializer()).serializeToString(clone);
}

View file

@ -709,7 +709,7 @@ function applyStyleOnLoad() {
stylePreset.value = preset;
stylePreset.dataset.old = preset;
} else {
if (preset !== "styleDefault" && ERROR) console.error(`Style preset ${preset} is not available in localStorage, applying default style`);
if (preset && preset !== "styleDefault" && ERROR) console.error(`Style preset ${preset} is not available in localStorage, applying default style`);
stylePreset.value = "styleDefault";
stylePreset.dataset.old = preset;
applyDefaultStyle();