SVG辉光滤镜显示错误的颜色

时间:2018-07-24 14:45:36

标签: svg svg-filters

我几乎准确地使用了filter code from here(只是使用泛色,半径和标准偏差来获得我想要的确切效果):

    <defs>
        <filter id="sofGlow" height="300%" width="300%" x="-75%" y="-75%">
        <feMorphology operator="dilate" radius="4" in="SourceAlpha" result="thicken" />
        <feGaussianBlur in="thicken" stdDeviation="10" result="blurred" />
        <feFlood flood-color="rgb(0,186,255)" result="glowColor" />
        <feComposite in="glowColor" in2="blurred" operator="in" result="softGlow_colored" />
        <feMerge>
            <feMergeNode in="softGlow_colored"/>
            <feMergeNode in="SourceGraphic"/>
        </feMerge>
    </filter>
</defs>

我将它应用于正在研究的一个SVG,结果如预期的那样-淡蓝色的光泽。

然后我尝试将其应用于另一个SVG,结果却像黑色的辉光。我什至尝试将洪水颜色更改为rgb(255, 0, 0),但它仍然看起来是黑色的。

为什么会那样做,我该怎么解决?

1 个答案:

答案 0 :(得分:0)

这里是演示。 https://codepen.io/vccodepen/pen/qyjoNr

您可以设置两个过滤器,并在同一<svg>中指定不同的ID名称。在其他<svg>中,只需分配所需的过滤器ID即可。

相关问题