微信小程序canvas在其他图片上画圆形图片

wx.downloadFile({
      url: app.globalData.imgUrl2 + self.data.imgNumber+'.png', 
      success(res0) {
        if (res0.statusCode === 200) {
          console.log(res0)
          var card=res0.tempFilePath
          console.log(card)
          const ctx = wx.createCanvasContext('myCanvas')
          
          ctx.drawImage(res0.tempFilePath, 0, 0, rpx(750), rpx(1222));
          
          wx.downloadFile({
            url:baseUrl+"?act=app",
            success(res){
              if(res.statusCode===200){
                var EWM=res.tempFilePath
                ctx.save()
                ctx.beginPath()
                ctx.arc(rpx(244), rpx(1068), rpx(66), 0, 2 * Math.PI)
                ctx.clip()
                ctx.drawImage(EWM, rpx(178), rpx(1002), rpx(132), rpx(132))
                ctx.restore()
                ctx.draw(true,function(){
                  let timer = setTimeout(function () {
                    wx.canvasToTempFilePath({
                      canvasId: 'myCanvas',
                      success(res2) {
                        console.log(222)
                        console.log(res2.tempFilePath)
                        wx.hideLoading();
                        wx.navigateTo({
                          url: '/pages/selfCard/selfCard?url=' + res2.tempFilePath,
                        })
                      }
                    }, self)
                  }, 500);
                })
                
              }
            }
          })
          
        }
      }
    })

 

你可能感兴趣的:(微信小程序)