1 回复
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() |