![乳胶中的动画证明](https://linux22.com/image/332482/%E4%B9%B3%E8%83%B6%E4%B8%AD%E7%9A%84%E5%8A%A8%E7%94%BB%E8%AF%81%E6%98%8E.png)
答案1
这是一个非常精致的动画,所以这是一个开始。如果您遇到问题(很可能会有),请随时提出新问题,但请记住将重点放在您遇到的特定问题上。
添加tikz
到standalone
类别选项可让你的 pdf 每帧有一页。
要将其编译为 .gif,请安装图像魔法在您的系统中,然后在您的终端/命令提示符中执行以下操作:
convert -delay 10 -loop 0 -density 300 -scale 400 -alpha remove file.pdf file.gif
其中file.pdf
是您的文件名,file.gif
是生成的 .gif 文件的名称,请相应地更改名称。
输出
代码
\documentclass[tikz, margin=10pt]{standalone}
\newcommand\basicstuff{
\path (-5,-3) rectangle (5,3);
}
\tikzset{
bas/.style={text width=4cm}
}
\begin{document}\Huge
\foreach \x in {0,...,10}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};
\end{tikzpicture}
}
%
\foreach \x [
count=\xx starting from 0,
evaluate=\x as \opac using (\x/10),
evaluate=\x as \y using (3-\x)
] in {0,.25,...,2}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};
\node[bas, opacity=\opac] at (-\x,\y) {$\textcolor{red}{axx}$};
\end{tikzpicture}
}
%
\foreach \x in {1,...,10}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};
\node[bas] at (-2,1) {$\textcolor{red}{axx}$};
\end{tikzpicture}
}
%
\foreach \y [
count=\xx starting from 0,
evaluate=\xx as \xi using (-2.75-(.25*-\xx*1.5)),
evaluate=\xx as \yi using (.8-(.25*\xx*2.5)),
evaluate=\y as \x using (1-\y)
] in {1,.8,...,0}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};
\filldraw[draw=red, fill=red!50] (-2.75,.6) rectangle (\xi,\yi);
\path (-2.75,.8) -- (-2.75,\yi) node[left, midway] {$\textcolor{red}{ax}$};
\path (-2.75,.5) -- (\xi,.5) node[above, midway] {$\textcolor{red}{x}$};
\end{tikzpicture}
}
%
\foreach \x in {1,...,10}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};
\filldraw[draw=red, fill=red!50] (-2.75,.6) rectangle (-.875,-2.325);
\path (-2.75,.8) -- (-2.75,-2.325) node[left, midway] {$\textcolor{red}{ax}$};
\path (-2.75,.5) -- (-.875,.5) node[above, midway] {$\textcolor{red}{x}$};
\end{tikzpicture}
}
\end{document}