This is a code I try to use to animate a proof of Pythagoras theorem :
\documentclass[tikz]{standalone}
\begin{document}
\foreach \t in {0,0.2,...,1}{%
\begin{tikzpicture}[rounded corners = 0.3pt,opacity=0.5]
\newcommand\lc{10cm};
\newcommand\anga{37};
\coordinate (A) at (0,0);
\coordinate (B) at (\lc,0);
\coordinate (C) at (\lc,\lc);
\coordinate (D) at (0,\lc);
\coordinate (E) at
({\lccos(\anga)cos(\anga)},{\lccos(\anga)sin(\anga)});
\coordinate (F) at
({\lc-\lccos(\anga)sin(\anga)},{\lccos(\anga)cos(\anga)});
\coordinate (G) at
({\lc-\lccos(\anga)cos(\anga)},{\lc-\lccos(\anga)sin(\anga)});
\coordinate (H) at
({\lccos(\anga)sin(\anga)},{\lc-\lccos(\anga)cos(\anga)});
\filldraw[very thick,black,fill=blue!50!white,draw=black] (A) --
(B) -- (E) -- cycle;
\filldraw[very thick,black,fill=orange,draw=black] (B) -- (C) --
(F) -- cycle;
\begin{scope}[yshift=-\lc*\t]
\filldraw[very thick,black,fill=green!50!white,draw=black]
(C) -- (D) -- (G) -- cycle;
\end{scope}
\filldraw[very thick,black,fill=red!50!white,draw=black] (D) --
(A) -- (H) -- cycle;
\filldraw[very thick,black,fill=yellow,draw=black] (E) -- (F) --
(G) -- (H) -- cycle;
\end{tikzpicture}
}
\end{document}
Problem is : the green triangle is not shifted down... I tried applying the transformation to each point of the triangle with "++()" (even to the "cycle"), sometimes, but not always, the triangle simply disappear...
Where did I go wrong ?
Thanks for any help.
\tparameter. Try to comment the line\newcommand\anga{37};and replace the\foreach…line by\foreach \anga in {45,40,...,20}{%– NBur Feb 22 '21 at 16:04shiftdoesn't act withinscopeon defined coordinates (for what I've tested). As a workaround, you can code\filldraw[very thick,black,fill=green!50!white,draw=black] ([yshift=-\lc*\t]C) -- ([yshift=-\lc*\t]D) -- ([yshift=-\lc*\t]G) -- cycle;(without thescopeenvironment). – NBur Feb 22 '21 at 16:20