Laden…

Online kleuren
'; document.body.appendChild(frame); }catch(e){if(frame)frame.remove();activePrintFrame=null;status(text.print_error)} }; window.addEventListener('pagehide',persist);document.addEventListener('visibilitychange',()=>{if(document.visibilityState==='hidden')persist()}); window.addEventListener('beforeunload',e=>{if(changed){persist();e.preventDefault();e.returnValue=''}}); function loadImage(src){return new Promise((resolve,reject)=>{const image=new Image();image.onload=()=>resolve(image);image.onerror=reject;image.src=src})} const img=new Image(); img.onload=async()=>{ const scale=Math.min(1,1600/Math.max(img.naturalWidth,img.naturalHeight));base.width=ink.width=layer.width=Math.max(1,Math.round(img.naturalWidth*scale));base.height=ink.height=layer.height=Math.max(1,Math.round(img.naturalHeight*scale));baseCtx.fillStyle='#fff';baseCtx.fillRect(0,0,base.width,base.height);baseCtx.drawImage(img,0,0,base.width,base.height); let restored=false; try{const saved=await readSaved();if(saved&&saved.version===1&&saved.sourceWidth===img.naturalWidth&&saved.sourceHeight===img.naturalHeight&&Number.isInteger(saved.rotation)&&saved.rotation>=0&&saved.rotation<4){const picture=await loadImage(saved.png);const expectedW=saved.rotation%2?base.height:base.width,expectedH=saved.rotation%2?base.width:base.height;if(picture.naturalWidth===expectedW&&picture.naturalHeight===expectedH){rotation=saved.rotation;for(let i=0;istatus(text.load_error);img.src=imageUrl; })();