添加一个圆角矩形至当前路径
// 可通过 canvascontext 现有的方法间接实现,参考代码如下
roundrect(ctx, x, y, width, height, radius) {
ctx.moveto(x radius, y); // 移动到左上角的右侧
ctx.lineto(x width - radius, y); // 绘制到右上角的左侧
ctx.quadraticcurveto(x width, y, x width, y radius); // 右上角的圆弧
ctx.lineto(x width, y height - radius); // 绘制到右下角的上侧
ctx.quadraticcurveto(x width, y height, x width - radius, y height); // 右下角的圆弧
ctx.lineto(x radius, y height); // 绘制到左下角的右侧
ctx.quadraticcurveto(x, y height, x, y height - radius); // 左下角的圆弧
ctx.lineto(x, y radius); // 绘制到左上角的下侧
ctx.quadraticcurveto(x, y, x radius, y); // 左上角的圆弧
}