diff --git a/min/script.min.js b/min/script.min.js index b0bbe19..2e77044 100644 --- a/min/script.min.js +++ b/min/script.min.js @@ -1 +1 @@ -"use strict";const{isArray:A}=Array;const _=a=>typeof a==='number';var c=document.querySelector('.canvas'),d=document.querySelector('.reset'),B=document.querySelector('.generate'),f=document.querySelector('.undo'),g=document.querySelector('.setBtn'),h=c.getContext('2d'),I=document.querySelector('.design'),j=document.querySelector('.user-design'),k=document.querySelector('.save'),l=document.querySelector('.popup_saved'),m=document.querySelector('.curve-input-container'),N=document.querySelector('.btn-close'),o=localStorage.getItem('canvasArray'),p=e=>{aD();aH();aE();z(e)};let q='1';let r='#000000';let s;let t;let x;let y;let w=-1;let X=[];let Y=!1;function z(C){h&&(h.beginPath(),h.strokeStyle=r,h.lineWidth=+q,h.moveTo(x,y),h.lineTo(C.offsetX,C.offsetY),h.stroke());}function aA(n){return _(n)}function aB(){X.length===0?I.value='[ ]':I.value=JSON.stringify(X);;I.select()}function aC(){var _a=X[X.length-1];if(aA(_a)){for(let i=0;i<4;i++)X.pop();;w-=4}else A(_a)&&(X.pop(),w--);};function aD(){h===null||h===void 0?void 0:h.clearRect(0,0,c.width,c.height)};function aE(){let i=0;if(h){h.beginPath();h.strokeStyle='#000000';h.lineWidth=1;while (iconst canvas = document.querySelector(\'canvas\');
const ctx = canvas.getContext(\'2d\');
ctx.beginPath();
ctx.strokeStyle = '#000000';
ctx.lineWidth = 1;
`;while (ictx.moveTo(${E}, ${aJ});`;_A.innerHTML+=`
ctx.lineTo(${X[i+2]}, ${X[i+3]});
`;i+=4}else if(A(E)){_A.innerHTML+=`
ctx.moveTo(${E[0]}, ${E[1]});
`;_A.innerHTML+=`
ctx.quadraticCurveTo(${E[2]}, ${E[3]}, ${E[4]}, ${E[5]});
`;i++}else{if(!(aA(E)||aA(aJ))&&!A(aJ)){_A.innerHTML+=`
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = '${E}';
`;_A.innerHTML+=`
ctx.lineWidth = '${aJ}';
`;i+=2}else{Math.sign(+E)?(_A.innerHTML+=`
ctx.stroke();
ctx.beginPath();
ctx.lineWidth = '${E}';
`,i++):(_A.innerHTML+=`
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = '${E}';
`,i++);}}};_A.innerHTML+='
ctx.stroke();
';_c===null||_c===void 0?void 0:_c.removeAllRanges();_B.selectNodeContents(_A);_c===null||_c===void 0?void 0:_c.addRange(_B)}};function aG(aK,...aL){if(aK==='def'){var _C=window.innerHeight,_d=window.innerWidth;c.width=(_d/100)*70;c.height=(_C/100)*72.5}else{c.width=aL[0];c.height=aL[1]}}function aH(){var aM=2.5*parseFloat(getComputedStyle(document.documentElement).fontSize);s=+document.querySelector('.width').value||c.width;t=+document.querySelector('.height').value||c.height;if(h){h.beginPath();h.strokeStyle='#AAAAAA';h.lineWidth=1;for(let x=0;x<=s;x+=aM){h.moveTo(x,0);h.lineTo(x,t)}for(let y=0;y<=t;y+=aM){h.moveTo(0,y);h.lineTo(s,y)}h.stroke()}};function aI(){var aN=document.querySelector('.curveX'),aO=document.querySelector('.curveY'),aP=X[X.length-1];let _D=[];if(X.length!==0){if(aA(aP)){for(let i=0;i<4;i++)_D.push(X.pop());;w=w-3;_D.reverse()};if(A(aP)){for(let i=0;i<4;i++)_D.push(aP[i]);;X.pop()};_D.push((c.width/100)* +aN.value);_D.push((c.height/100)* +aO.value);X.push(_D)}};aG('def');aH();o!==null&&(X=JSON.parse(o),aE());aB();window.addEventListener('resize',e=>{s=+document.querySelector('.width').value;t=+document.querySelector('.height').value;!(s&&t)?aG('def'):aG('custom',s,t);aD();aH();aE()});window.addEventListener('beforeunload',e=>{(localStorage.getItem('canvasArray')!==JSON.stringify(X)&&!Y)&&(e.preventDefault(),Y=!0)});c.addEventListener('contextmenu',e=>e.preventDefault());c.addEventListener('pointerdown',e=>{var aQ=document.querySelector('.stroke-width').value,aR=document.querySelector('.color').value;aR!==r&&(r=aR,w++,X[w]=r);(aQ&&aQ!==q)&&(q=aQ,w++,X[w]=q);x=Math.round(e.offsetX);y=Math.round(e.offsetY);w++;X[w]=x;w++;X[w]=y;c.addEventListener('pointermove',p)});c.addEventListener('pointerup',e=>{let a=Math.round(e.offsetX);let b=Math.round(e.offsetY);aD();aH();aE();c.removeEventListener('pointermove',p);w++;X[w]=a;w++;X[w]=b;h&&(h.beginPath(),h.strokeStyle=r,h.lineWidth=+q,h.moveTo(x,y),h.lineTo(a,b),h.stroke());;aB()});f===null||f===void 0?void 0:f.addEventListener('click',()=>{aD();aC();aH();aE();aB()});B===null||B===void 0?void 0:B.addEventListener('click',()=>aF());d===null||d===void 0?void 0:d.addEventListener('click',()=>{aD();aH();X=[];w=-1;localStorage.removeItem('canvasArray');q='1';r='#000000';aB()});g===null||g===void 0?void 0:g.addEventListener('click',()=>{s=+document.querySelector('.width').value;t=+document.querySelector('.height').value;aG('custom',s,t);aH();aE()});k===null||k===void 0?void 0:k.addEventListener('click',()=>{localStorage.setItem('canvasArray',JSON.stringify(X));w=w+X.length;l.classList.add('show');N===null||N===void 0?void 0:N.addEventListener('click',()=>{clearTimeout(aS);l.classList.remove('show')});var aS=setTimeout(()=>l.classList.remove('show'),2300)});j===null||j===void 0?void 0:j.addEventListener('click',()=>{aD();X=JSON.parse(document.querySelector('.design').value);aH();aE();aB()});m.addEventListener('input',e=>{var aT=e.target,aU=aT.value;if(aT.classList.contains('curveX')){var aV=document.querySelector('.curveXupdate');aV.innerHTML=aU}else{var _e=document.querySelector('.curveYupdate');>>>>>>> main +"use strict";const{isArray:A}=Array;const _=a=>typeof a==='number';var c=document.querySelector('.canvas'),d=document.querySelector('.reset'),B=document.querySelector('.generate'),f=document.querySelector('.undo'),g=document.querySelector('.setBtn'),h=c.getContext('2d'),I=document.querySelector('.design'),j=document.querySelector('.user-design'),k=document.querySelector('.save'),l=document.querySelector('.popup_saved'),m=document.querySelector('.curve-input-container'),N=document.querySelector('.btn-close'),o=localStorage.getItem('canvasArray'),p=e=>{aD();aH();aE();z(e)};let q='1';let r='#000000';let s;let t;let x;let y;let w=-1;let X=[];let Y=!1;function z(C){h&&(h.beginPath(),h.strokeStyle=r,h.lineWidth=+q,h.moveTo(x,y),h.lineTo(C.offsetX,C.offsetY),h.stroke());}function aA(n){return _(n)}function aB(){X.length===0?I.value='[ ]':I.value=JSON.stringify(X);;I.select()}function aC(){var _a=X[X.length-1];if(aA(_a)){for(let i=0;i<4;i++)X.pop();;w-=4}else A(_a)&&(X.pop(),w--);};function aD(){h===null||h===void 0?void 0:h.clearRect(0,0,c.width,c.height)};function aE(){let i=0;if(h){h.beginPath();h.strokeStyle='#000000';h.lineWidth=1;while (iconst canvas = document.querySelector(\'canvas\');
const ctx = canvas.getContext(\'2d\');
ctx.beginPath();
ctx.strokeStyle = '#000000';
ctx.lineWidth = 1;
`;while (ictx.moveTo(${E}, ${aJ});`;_A.innerHTML+=`
ctx.lineTo(${X[i+2]}, ${X[i+3]});
`;i+=4}else if(A(E)){_A.innerHTML+=`
ctx.moveTo(${E[0]}, ${E[1]});
`;_A.innerHTML+=`
ctx.quadraticCurveTo(${E[2]}, ${E[3]}, ${E[4]}, ${E[5]});
`;i++}else{if(!(aA(E)||aA(aJ))&&!A(aJ)){_A.innerHTML+=`
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = '${E}';
`;_A.innerHTML+=`
ctx.lineWidth = '${aJ}';
`;i+=2}else{Math.sign(+E)?(_A.innerHTML+=`
ctx.stroke();
ctx.beginPath();
ctx.lineWidth = '${E}';
`,i++):(_A.innerHTML+=`
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = '${E}';
`,i++);}}};_A.innerHTML+='
ctx.stroke();
';_c===null||_c===void 0?void 0:_c.removeAllRanges();_B.selectNodeContents(_A);_c===null||_c===void 0?void 0:_c.addRange(_B)}};function aG(aK,...aL){if(aK==='def'){var _C=window.innerHeight,_d=window.innerWidth;c.width=(_d/100)*70;c.height=(_C/100)*72.5}else{c.width=aL[0];c.height=aL[1]}}function aH(){var aM=2.5*parseFloat(getComputedStyle(document.documentElement).fontSize);s=+document.querySelector('.width').value||c.width;t=+document.querySelector('.height').value||c.height;if(h){h.beginPath();h.strokeStyle='#AAAAAA';h.lineWidth=1;for(let x=0;x<=s;x+=aM){h.moveTo(x,0);h.lineTo(x,t)}for(let y=0;y<=t;y+=aM){h.moveTo(0,y);h.lineTo(s,y)}h.stroke()}};function aI(){var aN=document.querySelector('.curveX'),aO=document.querySelector('.curveY'),aP=X[X.length-1];let _D=[];if(X.length!==0){if(aA(aP)){for(let i=0;i<4;i++)_D.push(X.pop());;w=w-3;_D.reverse()};if(A(aP)){for(let i=0;i<4;i++)_D.push(aP[i]);;X.pop()};_D.push((c.width/100)* +aN.value);_D.push((c.height/100)* +aO.value);X.push(_D)}};aG('def');aH();o!==null&&(X=JSON.parse(o),w=w+X.length,aE());aB();window.addEventListener('resize',e=>{s=+document.querySelector('.width').value;t=+document.querySelector('.height').value;!(s&&t)?aG('def'):aG('custom',s,t);aD();aH();aE()});window.addEventListener('beforeunload',e=>{(localStorage.getItem('canvasArray')!==JSON.stringify(X)&&!Y)&&(e.preventDefault(),Y=!0)});c.addEventListener('contextmenu',e=>e.preventDefault());c.addEventListener('pointerdown',e=>{var aQ=document.querySelector('.stroke-width').value,aR=document.querySelector('.color').value;aR!==r&&(r=aR,w++,X[w]=r);(aQ&&aQ!==q)&&(q=aQ,w++,X[w]=q);x=Math.round(e.offsetX);y=Math.round(e.offsetY);w++;X[w]=x;w++;X[w]=y;c.addEventListener('pointermove',p)});c.addEventListener('pointerup',e=>{let a=Math.round(e.offsetX);let b=Math.round(e.offsetY);aD();aH();aE();c.removeEventListener('pointermove',p);w++;X[w]=a;w++;X[w]=b;h&&(h.beginPath(),h.strokeStyle=r,h.lineWidth=+q,h.moveTo(x,y),h.lineTo(a,b),h.stroke());;aB()});f===null||f===void 0?void 0:f.addEventListener('click',()=>{aD();aC();aH();aE();aB()});B===null||B===void 0?void 0:B.addEventListener('click',()=>aF());d===null||d===void 0?void 0:d.addEventListener('click',()=>{aD();aH();X=[];w=-1;localStorage.removeItem('canvasArray');q='1';r='#000000';aB()});g===null||g===void 0?void 0:g.addEventListener('click',()=>{s=+document.querySelector('.width').value;t=+document.querySelector('.height').value;aG('custom',s,t);aH();aE()});k===null||k===void 0?void 0:k.addEventListener('click',()=>{localStorage.setItem('canvasArray',JSON.stringify(X));w=w+X.length;l.classList.add('show');N===null||N===void 0?void 0:N.addEventListener('click',()=>{clearTimeout(aS);l.classList.remove('show')});var aS=setTimeout(()=>l.classList.remove('show'),2300)});j===null||j===void 0?void 0:j.addEventListener('click',()=>{aD();X=JSON.parse(document.querySelector('.design').value);aH();aE();aB()});m.addEventListener('input',e=>{var aT=e.target,aU=aT.value;if(aT.classList.contains('curveX')){var aV=document.querySelector('.curveXupdate');aV.innerHTML=aU}else{var _e=document.querySelector('.curveYupdate');_e.innerHTML=aU};aD();aH();aI();aE();aB()});