考虑以下 MWE:
\documentclass[border=0pt,tikz]{standalone}
\definecolor{elila}{RGB}{186,85,211}
\definecolor{zlila}{RGB}{138,43,226}
\definecolor{dblau}{RGB}{30,144,255}
\definecolor{sblau}{RGB}{106,90,205}
\definecolor{brot}{RGB}{178,34,34}
\definecolor{mrot}{RGB}{128,0,0}
\definecolor{pgruen}{RGB}{152,251,152}
\definecolor{mgruen}{RGB}{60,179,113}
\begin{document}
\begin{tikzpicture}
\foreach \x in {0,1,...,5}
\foreach \y in {0,1,...,5}
{
\pgfmathsetmacro\random{int(random(1,3))}
\pgfmathsetmacro\rangle{\random*90}
\ifnum\random=1
\begin{scope}[shift={(\x,\y)},rotate around={(\rangle:(.5,.5))}]
\fill[brot] (0,0) -- (1,0) -- (0,1) -- cycle;
\fill[mrot] (1,0) -- (1,1) -- (0,1) -- cycle;
\end{scope}
\fill[shift={(\x,\y)},mrot] ([shift={(.5,.5)}]-135:.25) arc(-135:-135+180:.25);
\fill[shift={(\x,\y)},brot] ([shift={(.5,.5)}]45:.25) arc(45:45+180:.25);
\fi
\ifnum\random=2
\begin{scope}[shift={(\x,\y)},rotate around={(\rangle:(.5,.5))}]
\fill[pgruen] (0,0) -- (1,0) -- (0,1) -- cycle;
\fill[mgruen] (1,0) -- (1,1) -- (0,1) -- cycle;
\end{scope}
\fill[shift={(\x,\y)},mgruen] ([shift={(.5,.5)}]-135+90:.25) arc(-135+90:-135+90+180:.25);
\fill[shift={(\x,\y)},pgruen] ([shift={(.5,.5)}]45+90:.25) arc(45+90:45+90+180:.25);
\fi
\ifnum\random=3
\begin{scope}[shift={(\x,\y)},rotate around={(\rangle:(.5,.5))}]
\fill[elila] (0,0) -- (1,0) -- (0,1) -- cycle;
\fill[zlila] (1,0) -- (1,1) -- (0,1) -- cycle;
\end{scope}
\fill[shift={(\x,\y)},elila] ([shift={(.5,.5)}]-135:.25) arc(-135:-135+180:.25);
\fill[shift={(\x,\y)},zlila] ([shift={(.5,.5)}]45:.25) arc(45:45+180:.25);
\fi
}
\end{tikzpicture}
\end{document}
以下是输出(模式的外观取决于系统时间):
我的问题是:我如何才能实现每秒(范围:10 秒)获得一个单独的“帧”这种模式?因为对于随机模式,使用系统时间,每分钟都会发生变化,但它仍然是相同的“帧”。
.pdf
当我将文件转换为时,我想要获得.gif
动画。
答案1
我很乐意删除它(另一方面它看起来不错;-)。
\documentclass[border=0pt,tikz]{standalone}
\definecolor{elila}{RGB}{186,85,211}
\definecolor{zlila}{RGB}{138,43,226}
\definecolor{dblau}{RGB}{30,144,255}
\definecolor{sblau}{RGB}{106,90,205}
\definecolor{brot}{RGB}{178,34,34}
\definecolor{mrot}{RGB}{128,0,0}
\definecolor{pgruen}{RGB}{152,251,152}
\definecolor{mgruen}{RGB}{60,179,113}
\begin{document}
\foreach \X in {1,...,42}
{ \begin{tikzpicture}
\pgfmathsetseed{\X}
\foreach \x in {0,1,...,5}
\foreach \y in {0,1,...,5}
{
\pgfmathsetmacro\random{int(random(1,3))}
\pgfmathsetmacro\rangle{\random*90}
\ifnum\random=1
\begin{scope}[shift={(\x,\y)},rotate around={(\rangle:(.5,.5))}]
\fill[brot] (0,0) -- (1,0) -- (0,1) -- cycle;
\fill[mrot] (1,0) -- (1,1) -- (0,1) -- cycle;
\end{scope}
\fill[shift={(\x,\y)},mrot] ([shift={(.5,.5)}]-135:.25) arc(-135:-135+180:.25);
\fill[shift={(\x,\y)},brot] ([shift={(.5,.5)}]45:.25) arc(45:45+180:.25);
\fi
\ifnum\random=2
\begin{scope}[shift={(\x,\y)},rotate around={(\rangle:(.5,.5))}]
\fill[pgruen] (0,0) -- (1,0) -- (0,1) -- cycle;
\fill[mgruen] (1,0) -- (1,1) -- (0,1) -- cycle;
\end{scope}
\fill[shift={(\x,\y)},mgruen] ([shift={(.5,.5)}]-135+90:.25) arc(-135+90:-135+90+180:.25);
\fill[shift={(\x,\y)},pgruen] ([shift={(.5,.5)}]45+90:.25) arc(45+90:45+90+180:.25);
\fi
\ifnum\random=3
\begin{scope}[shift={(\x,\y)},rotate around={(\rangle:(.5,.5))}]
\fill[elila] (0,0) -- (1,0) -- (0,1) -- cycle;
\fill[zlila] (1,0) -- (1,1) -- (0,1) -- cycle;
\end{scope}
\fill[shift={(\x,\y)},elila] ([shift={(.5,.5)}]-135:.25) arc(-135:-135+180:.25);
\fill[shift={(\x,\y)},zlila] ([shift={(.5,.5)}]45:.25) arc(45:45+180:.25);
\fi
}
\end{tikzpicture}}
\end{document}