美文网首页
canvas绘制圆角矩形

canvas绘制圆角矩形

作者: ONE2 | 来源:发表于2021-07-19 13:56 被阅读0次

canvas绘制圆角矩形
https://blog.csdn.net/currencylee/article/details/80163753

drawRoundRect(cxt, x, y, width, height, radius){
cxt.beginPath();
cxt.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2);
cxt.lineTo(width - radius + x, y);
cxt.arc(width - radius + x, radius + y, radius, Math.PI * 3 / 2, Math.PI * 2);
cxt.lineTo(width + x, height + y - radius);
cxt.arc(width - radius + x, height - radius + y, radius, 0, Math.PI * 1 / 2);
cxt.lineTo(radius + x, height + y);
cxt.arc(radius + x, height - radius + y, radius, Math.PI * 1 / 2, Math.PI);
cxt.closePath();
},

相关文章

网友评论

      本文标题:canvas绘制圆角矩形

      本文链接:https://www.haomeiwen.com/subject/lxnikctx.html