我是靠谱客的博主 鲤鱼秀发,这篇文章主要介绍canvas画带圆角矩形,现在分享给大家,希望可以做个参考。

利用canvas画带圆角矩形,我使用的方法如下:

const borderRadius = 4
const x = 100
const y = 100
const borderWidth = 1
const width = 200
const height = 100
ctx.arc(x + borderRadius, y + borderRadius, borderRadius - borderWidth, 1 * Math.PI, 1.5 * Math.PI)
          ctx.lineTo(x + width - borderRadius, y + borderWidth)
          
          ctx.arc(x + width - borderRadius, y + borderRadius, borderRadius - borderWidth, 1.5 * Math.PI, 0)
          ctx.lineTo(x + width - borderWidth, y + height - borderRadius)
          
          ctx.arc(x + width - borderRadius, y + height - borderRadius, borderRadius - borderWidth, 0, 0.5 * Math.PI)
          ctx.lineTo(x + borderRadius, y + height - borderWidth)
          
          ctx.arc(x + borderRadius, y + height - borderRadius, borderRadius - borderWidth,  0.5 * Math.PI, Math.PI)
          ctx.lineTo(x + borderWidth, y + borderRadius)
          ctx.closePath()
          ctx.stroke()

最后

以上就是鲤鱼秀发最近收集整理的关于canvas画带圆角矩形的全部内容,更多相关canvas画带圆角矩形内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(117)

评论列表共有 0 条评论

立即
投稿
返回
顶部