Matter-js: I want to create a ring, how shuld I do

Created on 7 Sep 2018  路  3Comments  路  Source: liabru/matter-js

I created a ring by using SVG path ,but there are two gaps in the left and right of the ring, bodies inside of the ring can get out through gaps. And the ring is not so smooth.

here's the path:
d="m0,0a200,200 0 0 0 400,0a200,200 0 0 0 -400,0m5,0a195, 195 0 0 1 390, 0a195, 195 0 0 1 -390, 0z"

Could you please tell me how can I create a perfect ring.

or is there any way else to create a ring but not by using SVG path.

Thanks.

question

Most helpful comment

Using SVG is one way, though it might not be very optimal. It's probably better to build it from small overlapping rectangles, though I've never tried. Here are some examples that others have done though: example 1 example 2 example 3 example 4.

All 3 comments

Hi,

Maybe you can use a circle ?
Bodies.circle(x, y, radius)

Circle is not hollow, I want to add some bodies inside of the ring, it can not be realized by using a circle.

Using SVG is one way, though it might not be very optimal. It's probably better to build it from small overlapping rectangles, though I've never tried. Here are some examples that others have done though: example 1 example 2 example 3 example 4.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drachehavoc picture drachehavoc  路  4Comments

cain picture cain  路  4Comments

mrspeaker picture mrspeaker  路  3Comments

253153 picture 253153  路  3Comments

koko236 picture koko236  路  3Comments