// 将svg转成png
export const getSvgPngToSize = (osmd: any) => {
  if (osmd) {
    if (osmd.Drawer.Backends.length > 0) {
      var imgList = []
      
      for (var idx = 0, len = osmd.Drawer.Backends.length; idx < len; idx++) {
        var backend = osmd.Drawer.Backends[idx]
        var state = backend.ctx.state;
        var width = backend.ctx.width / state.scale.x;
        var height = backend.ctx.height / state.scale.y;
        const textX = width - 90,textY = height - 90;
        const textDom = `<g><text x="${textX}" y="${textY}" stroke-width="3" fill="#000000" stroke="none" stroke-dasharray="none" font-family="Times New Roman" font-size="36px" font-weight="bold" font-style="none">${idx+1}/${len}</text></g>`
        backend.ctx.svg.innerHTML = backend.ctx.svg.innerHTML + textDom;
        var cont = new XMLSerializer().serializeToString(
          backend.ctx.svg
        )
        imgList.push({
          img: cont,
          width: width,
          height: height,
        })
      }
      return imgList
    }
  } else {
    console.log('没有OSMD')
  }
}