在canvas上使用clip()画圆形头像,但是在真机上无法显示出来
发布于 4 年前 作者 jiejia 10220 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

用canvas画圆形头像使用clip()剪切,在真机上不显示

  • 预期表现

出现图片    编辑器上的显示

  • 复现路径
  • 提供一个最简复现 Demo

const ctx = wx.createCanvasContext(“canvasId”);

ctx.arc(headImgWidth / 2 + 30, headImgHeight / 2 + 53, headImgWidth / 2, Math.PI * 2, false);

ctx.clip();

ctx.drawImage(’/img/gem.jpg’, 30, 53, headImgWidth, headImgHeight);

ctx.restore();

ctx.draw();

6 回复

到底能能解决啊

我在使用ctx.clip()后调用ctx.drawImage在模拟器上可用,在真机上不显示图片,我保证图片已经下载在本地了

请问楼主,问题有没有解决问题啦?

圆形头像绘制需要下载到本地,才能在真机上绘制成功。我是可以的,希望有用!

请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

https://developers.weixin.qq.com/s/ggji2Vmk7W4J

这个是代码片段 ,我使用的测试机是小米8

回到顶部