首页 > 技术文章 > 小程序canvas绘制纯色圆角区域 setdata数组某一项

kerin 2020-10-29 17:52 原文

小程序canvas绘制纯色圆角区域:

//方法:
roundRectPath:function(ctx, x, y, w, h, r) {
  ctx.beginPath();
  ctx.moveTo(x + r, y);
  ctx.arcTo(x + w, y, x + w, y + h, r);
  ctx.arcTo(x + w, y + h, x, y + h, r);
  ctx.arcTo(x, y + h, x, y, r);
  ctx.arcTo(x, y, x + w, y, r);
  ctx.closePath();
},

//使用:
ctx.setFillStyle('#fff')
_this.roundRectPath(ctx,10, 370, 280, 80,10);
ctx.fill()

setdata数组某一项:

this.setData({
     ["IndexN[7]"]:3
 })

推荐阅读