"use strict";const t=require("../../../../common/vendor.js"),e=require("./poster/index.js");exports.useCanvas=async function(a,i){const r=a.width,h=new t.QSCanvas({canvasId:a.canvasId,width:a.width,height:a.height,setCanvasWH:t=>{a.height=t.height}},i);let s=await e.getPosterData(a);const d=await h.drawImg({type:"image",val:s.background,x:0,y:0,width:r,mode:"widthFix",zIndex:0});await h.updateCanvasWH({width:d.width,height:d.bottom});let o=s.list;for(let t=0;t<o.length;t++){let e=o[t];if("text"===e.type&&await h.drawText(e),"image"===e.type){e.d&&h.setCircle({x:e.x,y:e.y,d:e.d,clip:!0}),e.r&&h.setRect({x:e.x,y:e.y,height:e.height,width:e.width,r:e.r,clip:!0});try{await h.drawImg(e)}catch(c){console.log(c)}h.restore()}if("rect"===e.type){e.r&&h.setRect({x:e.x,y:e.y,height:e.height,width:e.width,r:e.r,clip:!0});try{await h.draw(e)}catch(c){console.log(c)}h.restore()}"qrcode"===e.type&&(console.log(e),await h.drawQrCode(e))}return await h.draw(),setTimeout((async()=>{a.src=await h.toImage()}),100),a};
