收藏
回答

canvas 怎么设置图片为圆形

canvas 怎么设置图片为圆形

回答关注问题邀请回答
收藏

1 个回答

  • 瑞克
    瑞克
    2017-10-28
    wx.createSelectorQuery().selectAll(".taste-canvas").boundingClientRect(function (rects) {
          rects.forEach(function (rect) {
            var ctx = wx.createCanvasContext(rect.dataset.id)
            var num = rect.dataset.num
            var color = rect.dataset.color
            var wd = rect.width / 2.6
            var po = rect.width / 2
            console.info(rect.width / 2)
            ctx.beginPath()
            ctx.setLineCap("round")
            ctx.setLineWidth(1)
            ctx.arc(po, po, wd, 0, 2 * Math.PI);
            ctx.setStrokeStyle("#f2f2f2");
            ctx.stroke();
            ctx.closePath();
     
            ctx.beginPath()
            ctx.arc(po, po, wd, 0, num * Math.PI);
            ctx.setStrokeStyle(color)
            ctx.setLineWidth(1)
            ctx.setGlobalAlpha(0.9)
            ctx.stroke()
            ctx.closePath();
            ctx.draw()
          })
     
        }).exec()


    2017-10-28
    有用
    回复
登录 后发表内容