如何在Matter.js中仅倒角两个角(矩形)?

发布于 2025-02-12 14:26:14 字数 138 浏览 1 评论 0 原文

我有一个矩形的物质。js身体,我只想倒出左上角和右上角,而不是底部。我该怎么做?

bodies.Rectangle(X,Y,W,H,{Chamfer:5})// Chamfers All Corners :( >

I have a rectangular matter.js body and I only want to chamfer the top-left and top-right corners, but not the bottom. How will I do that?

Bodies.rectangle(x, y, w, h, { chamfer: 5 }) // chamfers all corners :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柒七 2025-02-19 14:26:14

方法 bodies.Rectangle 调用 vertices.chamfer ,如这些倒角属性是对象。但是,如果您通过一个数字,它将将相同的倒角号应用于与在这里

通过文档,我们发现::

半径参数是单个数字或一个数组来指定每个顶点的半径。

对于矩形,顶点是从左上方开始的。毕竟,要倒角左上角和右上角,代码应为:

Bodies.rectangle(x, y, w, h, { 
  chamfer: {
    radius: [5,5,0,0]
  }
})

The method Bodies.rectangle calls Vertices.chamfer as found on these lines of code, and it expects that the chamfer property be an object. However, if you pass a single number it will apply the same chamfer number to all of the vertices as seen here.

Reading over the documentation, we found that:

The radius parameter is a single number or an array to specify the radius for each vertex.

For a rectangle, the vertices are clockwise starting from the top left. After all, to chamfer only the top left and top right corners, the code should be:

Bodies.rectangle(x, y, w, h, { 
  chamfer: {
    radius: [5,5,0,0]
  }
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文