I am working with this following and trying SMIL animation for the first time.
If you take a look, you would realize that the animation is not smooth, there is a jump at the end.
How can I make this to run smoothly without any jump?
<svg class="layer1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
<defs>
<filter id="trip">
<feTurbulence id="turbulence" baseFrequency="10" numOctaves="20" seed="10" stitchTiles="stitch">
<animate id="noiseAnimate" attributeName="baseFrequency" attributeType="XML" from="10" to="15" begin="0s" dur="5s" repeatCount="indefinite"></animate>
</feTurbulence>
<feDisplacementMap in="SourceGraphic" scale="1"></feDisplacementMap>
</filter>
</defs>
<rect class="bg" id="bg" width="200" height="200" fill="black">
</rect>
<rect class="bg" id="bg" x="50" y="50" width="30" height="30" fill="white" filter="url(#trip)">
</rect>
</svg>
Let's ignore the question whether your animation is a good choice, and just look at the syntax involved.
The behavior of this animation is just the same as the CSS property
animation-direction: normal:After moving from 10 to 15, it jumps back to 10 and starts over.
While CSS has a value of
animation-direction: alternateto describe an animation that moves smoothly forth and back, the same does not exist for SMIL. Instead, you have to describe a movement that has three values: the start value, the end value, and the start value again. This cannot be described with thefromandtoattributes, but withvalues.Additionally, you have to set the
keyTimesattribute. In an interval of 0...1 it describes when, relative to the simple duration, the value is reached.Note: For animating
baseFrequency, you have to setstitchTiles="noStitch", as otherwise the frequency is changed in such discrete steps that the Perlin cell size is always an integral fraction of the primitive filter region size.