本文主要是介绍LaTex+beamer+animate中批处理加载图像文件的方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
想做一个动画,这个动画有40幅图片构成,文件名是规范命名的,如:
moviefile1.jpg,moviefile2.jpg,...,moviefile40.jpg.一个一个第手工添加肯定会累死.
下面的代码定义了计数器和字符串变量,实现了批处理加载图像文件的方法,并演示了$MATLAB$中的动画功能,有点类似gif动画文件:
%%============================================
\begin{frame}[fragile]\frametitle{动画的小例子$plot5$}\framesubtitle{~$MATLAB$~简单的示例}\begin{columns}\column{0.425\textwidth}<1->\begin{center}
\tiny
\begin{lstlisting}[language=Matlab,numberstyle=\tiny, xleftmargin=1em,xrightmargin=0em, aboveskip=1em ]
%% 动画
maxj=40;
Z = peaks(maxj);
figure('Renderer','zbuffer');
surf(Z);
axis tight manual;
set(gca,'NextPlot','replaceChildren');
for j = 1:maxj
surf(sin(2*pi*j/maxj)*Z,Z)
F(j) = getframe;
fn=['moviefile',num2str(j),'.jpg'];
saveas(gcf,fn)
end
movie(F,2) % Play the movie 2 times
\end{lstlisting}
\end{center}\column{0.575\textwidth}<1->\setcounter{thirdcounter}{0}%设置计数器的值,每次增加一个值用
\begin{animateinline}[autoplay, loop, begin={\begin{tikzpicture}[scale=1] \useasboundingbox (-1cm,0cm) rectangle(5cm,6cm);}, end={\end{tikzpicture}}]{10} %总共生成40帧画面,以每秒10帧的速度自动播放 \multiframe{40}{Inum=0+1}{% %Inum:每帧\stepcounter{thirdcounter}\def\abc{moviefile\thethirdcounter} %定义动态字符串作为文件名\node[draw] at (2,3){\includegraphics[width=0.925\textwidth,totalheight=0.725\textheight]{\abc}}; }%
\end{animateinline} \end{columns}\end{frame}
最终的效果如下:
这篇关于LaTex+beamer+animate中批处理加载图像文件的方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!