![使用 tikz 装饰库和动画实现沿路径循环播放动画对象](https://linux22.com/image/457084/%E4%BD%BF%E7%94%A8%20tikz%20%E8%A3%85%E9%A5%B0%E5%BA%93%E5%92%8C%E5%8A%A8%E7%94%BB%E5%AE%9E%E7%8E%B0%E6%B2%BF%E8%B7%AF%E5%BE%84%E5%BE%AA%E7%8E%AF%E6%92%AD%E6%94%BE%E5%8A%A8%E7%94%BB%E5%AF%B9%E8%B1%A1.png)
如何使用 tikz 装饰库和动画来实现循环动画?简单示例显示圆圈围绕正方形的周长移动(生成的动画如下所示)。理想的结果应该是连续、循环的动画,没有“消失”的圆圈。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usepackage[export]{animate}
\begin{document}
\begin{animateinline}[autoplay,loop]{24}
\multiframe{160}{rt=0+0.0125*180}{
\begin{tikzpicture}
[
decoration={markings, mark=between positions {0+\rt/360} and 1 step .4 cm with {\draw circle [radius=.05cm];}},
]
\useasboundingbox (0,0) rectangle ++(3,3);
\draw [decorate] (0.5,0.5) rectangle ++(2,2);
\end{tikzpicture}
}
\end{animateinline}
\end{document}