SVG 滤镜动画 feColorMatrix

标签 svg svg-filters

我正在尝试使用 SVF 滤镜在图像上制作悬停效果。我的问题是我不知道如何让效果持久。我可以给出 1 秒的持续时间,但无法按照我的意愿保留 feColorMatrix

<filter id="blurred" color-interpolation-filters="sRGB" x="0%" y="0%" height="10%" width="10%">
  <feColorMatrix result="wispy" type="matrix" values="8 0 0 0 -1 4 0 4 3 -1 4 0 0 0 -1 1 0 0 0 0">
    <animate 
    attributeType="XML" 
    id="blurredAnimation" 
    attributeName="values" 
    from="8 0 0 0 -1 4 0 4 3 -1 4 0 0 0 -1 1 0 0 0 0" 
    to="3 0 0 0 -1 4 0 4 3 -1 4 0 0 0 -1 1 0 0 0 0" 
    dur="1s" 
    values = "8 0 0 0 -1 4 0 4 3 -1 4 0 0 0 -1 1 0 0 0 0;3 0 0 0 -1 4 0 4 3 -1 4 0 0 0 -1 1 0 0 0 0;"
    keyTimes = "0;1"
    begin="indefinite" />
  </feColorMatrix>
</filter>

我希望只要悬停在那里,绿色效果就一直存在。

谢谢

这是jsFiddle

最佳答案

如果添加 fill="freeze",动画将保持完成后的样子。您可能想添加一些内容到 reset the animation on mouseout too .

function toggleBlurOff(background) {
    document.getElementById("svg").setCurrentTime(0);
};

关于SVG 滤镜动画 feColorMatrix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31879033/

相关文章:

svg - 如何在 d3.js 中的图表节点上添加形状?

javascript - HTML/JS的Windows屏幕保护程序

html - 为什么 svg blur 在 html 或浏览器中不起作用?

css - SVG 棕褐色滤镜效果 : mid-tones only

html - Firefox 的模糊效果滤镜

html - Internet Explorer 中带阴影的 SVG 文本

svg - feImage 与内部来源

javascript - 从 paper.js 光栅导出 svg

java - 从 SVG 文件创建非缓冲的 java.awt.Image

html - 布局的 CSS 与 SVG