请问canvas如果画转弯运动

阅读 2.8k
2 个回答

圆弧直接用用 arcTo 函数, 送你一个圆角矩形路径函数

function roundRect(x, y, w, h, radius) {
    this.moveTo(x, y + h - radius[3]);
    this.arcTo(x, y, x + 1, y, radius[0]);
    this.arcTo(x + w, y, x + w, y + 1, radius[1]);
    this.arcTo(x + w, y + h, x - 1, y + h, radius[2]);
    this.arcTo(x, y + h, x, y, radius[3]);
}

roundRect.call(ctx,0,0,100,100,[10,10,10,10]) //四个角弧度半径都是 10 的圆角矩形
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题