如何从一组弧中计算圆的大小? 具体来说,我有这个SVG路径定义,它画一个圆圈,我希望掉其大小。

<path clip-path="url(#SVGID_2_)" fill="#99C44C" d="M334.293,56.846c0-4.782,3.88-8.659,8.665-8.659c4.78,0,8.66,3.877,8.66,8.659
    c0,4.783-3.88,8.661-8.66,8.661C338.173,65.507,334.293,61.629,334.293,56.846"/>
.

为您的信息,圆圈是在'd'属性中绘制的。M334.293,56.846移动到此x,y位置,然后c命令是曲线。

曲线:

使用(x1,y1)从电流点到(x,y)从曲线开始时的控制点和(x2,y2)作为曲线结束时的控制点。C(大写)表示绝对坐标将遵循;C(小写)表示将遵循相对坐标。

relative curves
c0-4.782,3.88-8.659,8.665-8.659
c4.78,0,8.66,3.877,8.66,8.659
c0,4.783-3.88,8.661-8.66,8.661

absolute curve
C338.173,65.507,334.293,61.629,334.293,56.846
.

有帮助吗?

解决方案

At this juncture you have two possibilites:

You can treat the bezier curve as a circle (which is, as commented, wrong; it's just really circle-looking). To calculate the area, determine the radius and use π * r^2 as usual.

If you want to calculate generally the area enclosed by a path element; that requires some moderate calculus, and is not for the faint of heart.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top