I have the following code earlier posted by Alenanno. I want to give an animated proof of quadratic formula. My question is:
- I want to improve the code so that when I am multiplying with
$4a$, then$4a$and$bx$comes down from equation no 2 and so on with$4aax^2$and$4ac.$ - Then I want
$a$and$\textcolor{red}{a}$to merge so it becomes $a^2$. How to do it?
\documentclass[tikz, margin=10pt]{standalone}
\newcommand\basicstuff{
\path (-9,-5) rectangle (9,5);
}
\tikzset{
bas/.style={text width=6cm}
}
\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}=0$};
\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}=0$};
\node[bas, opacity=\opac] at (0,\y) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
%\node[bas, opacity=\opac] at (3,\y) {$\textcolor{green}{bx}$};
\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}=0$};
\node[bas] at (0,1) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\end{tikzpicture}
}
%---------------------------
\foreach \x[ evaluate=\x as \opac using (\x/10),] in {1,...,10}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (0,1) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas, opacity=\opac] at (-0.2,0.88) {$( $}; %\hspace{4.4cm} \right) \hspace {1.cm}
\node[bas, opacity=\opac] at (4.4,0.88) {$)$};
\node[bas, opacity=\opac] at (-1.2,.88) {$4a\cdot$};
\node[bas, opacity=\opac] at (6,.88) {$\cdot4a$};
\end{tikzpicture}
}
%
%
%-------------------------------------------------------------------------------------------------------
\foreach \x[ evaluate=\x as \opac using (\x/10),] in {1,...,10}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (0,1) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (-0.2,0.88) {$( $}; %\hspace{4.4cm} \right) \hspace {1.cm}
\node[bas] at (4.4,0.88) {$)$};
\node[bas] at (-1.2,.88) {$4a\cdot$};
\node[bas] at (6,.88) {$\cdot4a$};
\node[bas, opacity=\opac] at (-0.9,-1.) {$4a \textcolor{red}{ax^2} \,$};
\end{tikzpicture}
}
%--------------------------------------------------------------------------------------------------------------------------
\foreach \x[ evaluate=\x as \opac using (\x/10),] in {1,...,10}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (0,1) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (-0.2,0.88) {$( $}; %\hspace{4.4cm} \right) \hspace {1.cm}
\node[bas] at (4.4,0.88) {$)$};
\node[bas] at (-1.2,.88) {$4a\cdot$};
\node[bas] at (6,.88) {$\cdot4a$};
\node[bas] at (-0.9,-1.) {$4a \textcolor{red}{ax^2} $};
\node[bas, opacity=\opac] at (1.5,-1.1) {$+ \,4a \textcolor{green}{bx}$};
\end{tikzpicture}
}
%--------------------------------------------------
%--------------------------------------------------------------------------------------------------------------------------
\foreach \x[ evaluate=\x as \opac using (\x/10),] in {1,...,10}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (0,1) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (-0.2,0.88) {$( $}; %\hspace{4.4cm} \right) \hspace {1.cm}
\node[bas] at (4.4,0.88) {$)$};
\node[bas] at (-1.2,.88) {$4a\cdot$};
\node[bas] at (6,.88) {$\cdot4a$};
\node[bas] at (-0.9,-1.) {$4a \textcolor{red}{ax^2} $};
\node[bas] at (1.5,-1.1) {$+ \,4a \textcolor{green}{bx}$};
\node[bas, opacity=\opac] at (4.2,-1.2) {$+ \,4a \textcolor{blue}{c}$};
\end{tikzpicture}
}
%-------------------------------------------------------------------------
\foreach \x[ evaluate=\x as \opac using (\x/10),] in {1,...,10}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (0,1) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (-0.2,0.88) {$( $}; %\hspace{4.4cm} \right) \hspace {1.cm}
\node[bas] at (4.4,0.88) {$)$};
\node[bas] at (-1.2,.88) {$4a\cdot$};
\node[bas] at (6,.88) {$\cdot4a$};
\node[bas] at (-0.9,-1.) {$4a \textcolor{red}{ax^2} $};
\node[bas] at (1.5,-1.1) {$+ \,4a \textcolor{green}{bx}$};
\node[bas] at (4.2,-1.2) {$+ \,4a \textcolor{blue}{c}$};
\node[bas, opacity=\opac] at (6.5,-1.2) {$ = 0 $};
\end{tikzpicture}
}
%-------------------------------------------------------------------------
\foreach \x[ evaluate=\x as \opac using (\x/10),] in {1,...,10,10,10,10,9,8,...,0}{
\begin{tikzpicture}
\basicstuff
\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (0,1) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}=0$};
\node[bas] at (-0.2,0.88) {$( $}; %\hspace{4.4cm} \right) \hspace {1.cm}
\node[bas] at (4.4,0.88) {$)$};
\node[bas] at (-1.2,.88) {$4a\cdot$};
\node[bas] at (6,.88) {$\cdot4a$};
\node[bas] at (-0.9,-1.) {$4a \textcolor{red}{ax^2} $};
\node[bas] at (1.5,-1.1) {$+ \,4a \textcolor{green}{bx}$};
\node[bas] at (4.2,-1.2) {$+ \,4a \textcolor{blue}{c}$};
\node[bas] at (6.5,-1.2) {$ = 0 $};
%\node[bas, opacity=\opac] at (-0.9,-1.) {$ 4 \textcolor{red}{a^2x^2}$};
\end{tikzpicture}
}
\end{document}
