gpt4 book ai didi

SVG 渐变作为具有绝对位置的折线描边背景

转载 作者:行者123 更新时间:2023-12-02 04:21:58 25 4
gpt4 key购买 nike

是否能够设置应用于折线的渐变背景的绝对位置?

例如当我设置渐变时:

<filter id="black-glow">
<feColorMatrix type="matrix" values=
"0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0" />
<feGaussianBlur stdDeviation="3" result="coloredBlur" />
<feMerge>
<feMergeNode in="coloredBlur" />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>

折线的笔划:

<polyline points="50,350 ... 350,239" style="fill:none;" stroke="url(#grad1)" stroke-width="3" stroke-linecap="round" />

(折线有最大/最小位置点)

结果没问题:

enter image description here

但是,当折线平坦时:

enter image description here

绿色的颜色要高得多。由于这是彩色图表,因此我需要实现不断查看背景,而与绘制折线的方式无关。

最佳答案

如果您希望将渐变应用于用户空间,则可以通过如下方式表达渐变:

<linearGradient id="grad1" gradientUnits="userSpaceOnUse" x1="0"
y1="350" x2="0" y2="220">

参见fiddle .

x1、y1、x2 和 y2 中的值将相对于当前用户空间坐标系,因此,如果您使用百分比,它们将相对于最近的视口(viewport),而不是相对于使用渐变的形状的边界框。请参阅svg specification了解详情。

关于SVG 渐变作为具有绝对位置的折线描边背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29750227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com