收藏
回答

Android 中 canvas bug

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug Canvas 客户端 6.7.3 2.3.0

- 当前 Bug 的表现(可附上截图)



iOS



Android


- 预期表现

如iOS

- 复现路径


- 提供一个最简复现 Demo

  var context = wx.createCanvasContext(this.data.canvasId, this);
 
let width = 5.62;
let height = 107;
let x = 36.69;
let y = 87.648;
let radius = [2.81, 2.81, 0, 0];
 
context.setFillStyle('green')
context.save();   // save the context so we don't mess up others
context.beginPath();
 
// draw top and top right corner
if (radius[0] === 0) {
  context.moveTo(x, y);
} else {
  context.moveTo(x + radius[0], y);
}
 
if (radius[1] === 0) {
  context.lineTo(x + width, y, x + width);
} else {
  context.arcTo(x + width, y, x + width, y + radius[1], radius[1]);
}
 
 
// draw right side and bottom right corner
if (radius[2] === 0) {
  context.lineTo(x + width, y + height);
} else {
  context.arcTo(x + width, y + height, x + width - radius[2], y + height, radius[2]);
}
 
// draw bottom and bottom left corner
if (radius[3] === 0) {
  context.lineTo(x, y + height);
} else {
  context.arcTo(x, y + height, x, y + height - radius[3], radius[3]);
}
 
// draw left and top left corner
if (radius[0] === 0 ) {
  context.lineTo(x, y);
} else {
  context.arcTo(x, y, x + radius[0], y, radius[0]);
}
 
 
  context.fill();
  context.stroke();
context.restore();    // restore context to what it was on entry
 
context.draw()


回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容