Rounded corners on triangle in SVG

落爺英雄遲暮 提交于 2019-12-05 19:27:21

I assume you only need this for right angle triangles with sides parallel to basic axes, this makes things a bit easier.

As you've said, the right angle is easy.

For other angles, you need to calculate centers of the circles. Let's say w and h are width and height of the triangle. Let's also say x, y are the coordinates of the rightmost node. The center of the rightmost triangle is: x - r * h / w, y - r. The angle that's covered by the arc you need to draw is π - α, where α is the corner angle you've calculated with atan.

Topmost corner will be handled similarly.

This should get you started.

Using the a command I can make very detailed corners with a certain rX and rY. I would call the function like:

a 5 5 0 0 1 0 5 5, and it will make a circle with radius 5 and dX = 5 and dY = 5. Which is perfect.

The radius is ideal at 90 degrees, so when I have a 50 degree corner I just use (50 / 90) * RADIUS for the values, and it's perfect.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!