嵌套多帧

嵌套多帧

我想知道以下是否可行。我想嵌套 animateinline 和 multiframe 环境来模拟信号对不同参数的时间依赖性。类似这样的:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{animate}

\begin{document}
   \centering
%\begin{animateinline}[poster=first, label=graph_switch,controls=step]{2}
 %     \multiframe{20}{rt=0+5}{%
 \def\rs{1}
\begin{animateinline}[poster=first, label=graph_switch, autoplay]{5}
    \multiframe{15}{rt=0+5}{%
        \begin{tikzpicture}
        %draw coordinate axis
        \draw[thick, color=black, -latex] (-4.05,0) -- (4.05,0) node[right]{$y$};              
        \draw[thick, color=black, -latex] (0,-1.4) -- (0,1.4) node[above]{$t$};
         \draw[scale=1, domain=-4:4, smooth, variable=\t, blue] plot ({\t}, {\rs*sin(100*\t+\rt)});
        \node at (5,5) {};
        \node at (-5,-5) {}; 
        \end{tikzpicture}
    }%
\end{animateinline}
% }%
% \end{animateinline}
 \end{document}

但是,这种嵌套似乎是不可能的,并且取消注释示例中的 4 行会导致错误。是否有任何解决方法可以实现类似的效果?

答案1

可以将动画分成多个部分,如下所示。在本例中,两个部分之间用暂停 ( \newframe*) 分隔。单击继续。

\documentclass{standalone}
\usepackage{tikz}
\usepackage{animate}

\begin{document}
\begin{animateinline}[poster=first, label=graph_switch, autoplay]{5}
  \multiframe{15}{rt=0+5}{%
    \def\rs{1}%
    \begin{tikzpicture}
    %draw coordinate axis
    \draw[thick, color=black, -latex] (-4.05,0) -- (4.05,0) node[right]{$y$};              
    \draw[thick, color=black, -latex] (0,-1.4) -- (0,1.4) node[above]{$t$};
      \draw[scale=1, domain=-4:4, smooth, variable=\t, blue] plot ({\t}, {\rs*sin(100*\t+\rt)});
      \node [anchor=north east] at (4,2) {$A=1$};
%    \node at (5,5) {};
%    \node at (-5,-5) {}; 
    \end{tikzpicture}
  }%
  \newframe*
  \multiframe{15}{rt=0+5}{%
    \def\rs{0.5}%
    \begin{tikzpicture}
    %draw coordinate axis
    \draw[thick, color=black, -latex] (-4.05,0) -- (4.05,0) node[right]{$y$};              
    \draw[thick, color=black, -latex] (0,-1.4) -- (0,1.4) node[above]{$t$};
      \draw[scale=1, domain=-4:4, smooth, variable=\t, blue] plot ({\t}, {\rs*sin(100*\t+\rt)});
      \node [anchor=north east] at (4,2) {$A=0.5$};
%    \node at (5,5) {};
%    \node at (-5,-5) {}; 
    \end{tikzpicture}
  }%
\end{animateinline}
\end{document}

相关内容