小程序
小游戏
企业微信
微信支付
扫描小程序码分享
canvas 怎么设置图片为圆形
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
wx.createSelectorQuery().selectAll(
".taste-canvas"
).boundingClientRect(
function
(rects) {
rects.forEach(
(rect) {
var
ctx = wx.createCanvasContext(rect.dataset.id)
num = rect.dataset.num
color = rect.dataset.color
wd = rect.width / 2.6
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.arc(po, po, wd, 0, num * Math.PI);
ctx.setStrokeStyle(color)
ctx.setGlobalAlpha(0.9)
ctx.stroke()
ctx.draw()
})
}).exec()
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
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()