[Latex]beamer中实现tikz的动画绘图的示例
2013-04-02 21:43
477 查看
在beamer中经常使用tikz绘图,有时想把图形的绘制过程动态地展现出来,就更好了.
下面是个例子:
编译上面的例子,打开生成的pdf文件就可以发现tikz的动态绘图过程是如何实现的了.
如下图中的带箭头的线段是如何动态生成的?
再看一个tikz动画(或动态)绘制正弦函数的例子:
绘图如下所示:
设置两个参数画正弦函数,总共生成20帧画面,已每秒10帧的速度播放:
效果如下:
最关键的宏包
下面是个例子:
% Animated beamer frame for tikz %Author: %wu xuping %Date: %2013-04-02 % FileName: %main.tex % run: % xelatex -shell-escape main % xelatex -shell-escape main %required: % Acrobat Reader version > 6 \documentclass{beamer} \usepackage{verbatim} \usepackage{tikz} \usepackage[autoplay,loop]{animate} \begin{document} \begin{frame} Animated beamer frame for tikz \begin{center} \begin{animateinline}[ begin={ \begin{tikzpicture}[blue,scale=1,line width=2pt] \useasboundingbox[draw] (0,0)rectangle(4,4); }, end={ \end{tikzpicture} } ]{2} \draw[->](0,0)--(1,1);\newframe \draw[->](0,0)--(2,2);\newframe \draw[->](0,0)--(3,3);\newframe \draw[->](0,0)--(4,4); \end{animateinline} \end{center} \end{frame} \end{document}
编译上面的例子,打开生成的pdf文件就可以发现tikz的动态绘图过程是如何实现的了.
如下图中的带箭头的线段是如何动态生成的?
再看一个tikz动画(或动态)绘制正弦函数的例子:
\documentclass{beamer} \usepackage{verbatim} \usepackage{ctex} \usepackage{tikz} \usepackage{animate} \newcommand{\plotsin}[1]{% \draw[red] plot[domain=-3:#1] (\x,{sin(\x r)}); } \begin{document} \begin{frame} 绘制正弦函数的动画:\\ \begin{animateinline}[autoplay,palindrome, begin={\begin{tikzpicture}[scale=1,line width=1.5pt] \draw[line width=0.5pt,step=0.5,dashed,use as bounding box] (-4,-1.5)grid(4,1.5); \draw[->] (-4,0)--(4,0) node[below left]{$x$}; \draw[->] (0,-1.5)--(0,1.5)node[below left]{$y$}; }, end={\end{tikzpicture}}]{4} \plotsin{0};\newframe \plotsin{1};\newframe \plotsin{1.5};\newframe \plotsin{2};\newframe \plotsin{2.5};\newframe \plotsin{3};\newframe \plotsin{3.5};\newframe \plotsin{4}; \end{animateinline} \end{frame} \end{document}
绘图如下所示:
设置两个参数画正弦函数,总共生成20帧画面,已每秒10帧的速度播放:
\documentclass{beamer} \usepackage{verbatim} \usepackage{tikz} \usepackage{calc} \usepackage{animate} \newcommand{\plotsin}[2]{% \draw[red,<->] plot[domain=#1:#2] (\x,{sin(\x r)}); } \begin{document} \begin{frame} 绘制正弦函数的动画:\\ \begin{animateinline}[autoplay,palindrome, begin={\begin{tikzpicture}[scale=1,line width=1.5pt] \draw[line width=0.5pt,step=0.5,dashed,use as bounding box] (-4,-1.5)grid(4,1.5); \draw[->,blue] (-4,0)--(4,0) node[below left]{$x$}; \draw[->,blue] (0,-1.5)--(0,1.5)node[below left]{$y$}; }, end={\end{tikzpicture}}]{10} \multiframe{20}{Rxa=-0.2+-0.2, Rxb=0.2+0.2}{% %Rxa=-0.2,-0.4,...,-4.0 %Rxb=+0.2,+0.4,...,+4.0 \plotsin{\Rxa}{\Rxb}% }% \end{animateinline} \end{frame} \end{document}
效果如下:
最关键的宏包
\usepackage[autoplay,loop]{animate}里面提供的命令和环境
\begin{animateinline} <code text> \end{animateinline}具体参见手册吧
相关文章推荐
- [latex]在beamer中使用tikz和animate宏包绘制PDF动画的示例
- [Latex][beamer]PGF and TiKz中演示文字沿路径移动的动画
- Android自定义View绘图实现拖影动画
- 自定义控件三部曲之动画篇(十)——联合动画的XML实现与使用示例
- tikz的函数绘图示例
- jQuery实现的背景颜色渐变动画效果示例
- JS实现自定义状态栏动画文字效果示例
- 5分钟快速实现Android爆炸破碎酷炫动画特效的示例
- iOS AutoLayout阅读笔记4------->AutoLayout入门动画示例(纯IB实现)
- 绘图与动画之使用自定义属性与Quartz实现扇形加载动画
- Android自定义View绘图实现拖影动画
- (4.1.23.12)自定义控件三部曲之动画篇(十)——联合动画的XML实现与使用示例
- [latex]PGF 和 tikz中如何旋转图形的示例
- 基于Two.js实现星球环绕动画效果的示例
- Animation动画详解(十)——联合动画的XML实现与使用示例
- 绘图与动画之使用自定义属性与颜色渐变实现色带加载动画
- Python3实现的画图及加载图片动画效果示例
- c语言实现多线程动画程序示例
- jQuery Animation实现CSS3动画示例介绍
- android 动画Animation硬代码实现示例