安卓canvas stroke渐变失效

发布于 7 年前作者 junjin13278 次浏览最后编辑 7 年前来自 ask

canvas在安卓上setStrokeStyle使用渐变无效,显示为黑色

代码片段

var grd = ctx.createCircularGradient(this.data.centerPoint[0] - this.rpx(20), this.rpx(-20), this.rpx(150));

grd.addColorStop(0, ‘rgba(255,255,255,1)’);

grd.addColorStop(1, ‘rgba(69, 233, 247, 1)’);

ctx.beginPath();

ctx.setLineWidth(this.rpx(12));

ctx.arc(this.data.centerPoint[0], this.data.centerPoint[1], this.data.radius + this.rpx(5), 1.5 * Math.PI, (progress * 2 + 1.5) * Math.PI, false);

ctx.setStrokeStyle(grd);

ctx.stroke();

ctx.closePath();

  • 当前 Bug 的表现(可附上截图)
  • 预期表现
  • 复现路径

  • 提供一个最简复现 Demo

1 回复
guiyinghuang
guiyinghuang1 楼5 年前

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)