乳胶中的动画证明

乳胶中的动画证明

我怎样才能做出这样的事情?我更喜欢 tikz。在此处输入图片描述

答案1

这是一个非常精致的动画,所以这是一个开始。如果您遇到问题(很可能会有),请随时提出新问题,但请记住将重点放在您遇到的特定问题上。

添加tikzstandalone类别选项可让你的 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}

相关内容