致谢:reference
[SVG] 如何关闭路径(第一个点和最后一个点之间)并相应地填充区域: 这不是一个单一的路径,所以我不能在最后用'Z'关闭它
最佳答案
It's not a single path, so I can't close it with 'Z' at the end
首先加入路径。
例如。您链接中的样本最初是
<path xmlns="http://www.w3.org/2000/svg" fill="none" stroke="blue" stroke-width="8" d="M 60 60 C 111.55555555555557 160 163.11111111111114 260 220 300"/>
<path xmlns="http://www.w3.org/2000/svg" fill="none" stroke="red" stroke-width="8" d="M 220 300 C 276.88888888888886 340 339.11111111111114 320 420 300"/>
但是,如果您将第二个的 d
字符串附加到第一个并将第二个 M
(移动)替换为 L
(LineTo) ,你得到这个:
<path xmlns="http://www.w3.org/2000/svg" fill="cyan" stroke="red" stroke-width="8" d="M 60 60 C 111.55555555555557 160 163.11111111111114 260 220 300 L 220 300 C 276.88888888888886 340 339.11111111111114 320 420 300 Z"/>
其中一些绘制的东西来自链接站点,而不是我的答案中的代码。
关于javascript - 填充贝塞尔曲线 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44574508/