gpt4 book ai didi

javascript - 带有 FeTurbulences 的 SVG 形状失真

转载 作者:行者123 更新时间:2023-11-30 15:28:47 24 4
gpt4 key购买 nike

我的问题很简单:是否可以重现 this effect (圆形变形动画)与 SVG 滤镜?

我认为将 FeTurbulences 与 FeDisplacementMap 一起使用会很有趣,因为它适用于 static way .但实际上,我不知道我应该补间哪个属性以使动画更漂亮。

<feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="2" result="warp" seed="0" stichTitles="stitch"></feTurbulence>
<feDisplacementMap xChannelSelector="R" yChannelSelector="G" scale="30" in="SourceGraphic" in2="warp" />

如果您有其他解决方案(js 库、过滤器等):请不要犹豫。我对所有解决方案持开放态度;)

感谢您的考虑。

最佳答案

这就是您执行此类过滤器的方式。 baseFrequency 控制失真的粒度,scale 控制位移的大小,Animate 中的 dur 控制速度。我对比例进行了动画处理并添加了阴影以更好地匹配原始内容。

  <svg width="800px" height="600px">
<defs>
<filter id="distort">
<feTurbulence baseFrequency=".015" type="fractalNoise"/>
<feColorMatrix type="hueRotate" values="0">
<animate attributeName="values" from="0" to="360" dur="1s" repeatCount="indefinite"/>
</feColorMatrix>
<feDisplacementMap in="SourceGraphic" xChannelSelector="R" yChannelSelector="B" scale="20">
<animate attributeName="scale" values="0;20;50;0" dur="5s" repeatCount="indefinite"/>
</feDisplacementMap>
<feGaussianBlur stdDeviation="3"/>
<feComponentTransfer result="main">
<feFuncA type="gamma" amplitude="50" exponent="5"/>
</feComponentTransfer>

<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="10"/>
<feComposite operator="over" in="main"/>

</filter>
</defs>
<circle filter="url(#distort)" cx="200" cy="200" r="150" fill="red"/>
</svg>

关于javascript - 带有 FeTurbulences 的 SVG 形状失真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42557401/

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