javascript - 填充贝塞尔曲线 SVG

标签 javascript svg

致谢:reference

[SVG] 如何关闭路径(第一个点和最后一个点之间)并相应地填充区域:enter image description here 这不是一个单一的路径,所以我不能在最后用'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"/>

我还设置了fill=cyanenter image description here

其中一些绘制的东西来自链接站点,而不是我的答案中的代码。

关于javascript - 填充贝塞尔曲线 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44574508/

相关文章:

css - svg 悬停时奇怪的蓝色下划线

javascript - 如何使用 Express res.send() 发送数组

javascript - (: ) character appended to data while making Ajax request

html - svg 作为背景图像颜色变化

javascript - 如何更改谷歌甘特图字体?

html - 如何在文本上使用 css 背景过滤器?

html - 使用 d3 在两个节点之间绘制多条边

javascript - 使前两列粘在表格中

javascript - 如何动态地为 vue2 传单标记着色?

javascript - 动态创建没有字符串的引用