canvas 生成图片 artTo 安卓下变形,ios 完好

发布于 6 年前作者 ming964827 次浏览最后编辑 6 年前来自 ask
  • 当前 Bug 的表现(可附上截图)

安卓下:

IOS下:

  • 预期表现

与IOS相同

  • 复现路径

  • 提供一个最简复现 Demo

2 回复
xiulan06
xiulan061 楼6 年前

你好,建议参考这个回答尝试解决问题,另外后续建议经过搜索后再提问,以提高解答问题的效率

小程序canvas切圆角矩形android存在兼容问题
https://developers.weixin.qq.com/blogdetail?action=get_post_info&docid=000c86e03d8788f1dfa6a969d5b000&highline=canvas%20%E5%9C%86%E8%A7%92

mqiu
mqiu2 楼4 年前

// 圆角矩形

export function drawRoundedRect(options) {

  let { ctx, x, y, r, width, height, color, shadow } = options

  ctx.save()

 

  if (shadow) {

    ctx.setShadow(0, 0, shadow.offset, shadow.color)

  }

  ctx.setFillStyle(color)

  ctx.beginPath()

  ctx.moveTo(x + r, y)

  ctx.arcTo(x + width, y, x + width, y + height, r)

  ctx.arcTo(x + width, y + height, x, y + height, r)

  ctx.arcTo(x, y + height, x, y, r)

  ctx.arcTo(x, y, x + width, y, r)

  ctx.closePath()

  ctx.fill()

  ctx.restore()

}