使用 Tikz 绘制动画图像

使用 Tikz 绘制动画图像

经过多次尝试重现以下问题,但均未成功邮政为了绘制此图像动态图格式:

费城染色体

我绝望地想知道是否有可能用蒂克兹环境。

考虑了marmot的回答后,我仍然无法进行转换。

错误

有好心人能帮我做些什么吗?

答案1

生产

在此处输入图片描述

编译

\documentclass[tikz, border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}

\begin{document}
\foreach \X in {0,0.05,...,1}
{\begin{tikzpicture}
 %
 \path[use as bounding box](-0.2,-2) rectangle (4.2,3.1);
 \draw[line width=4mm,line cap=round,green!80!black!70!blue] (0,2) -- (0,3);
 \draw[line width=4mm,green!20!black,
 dash pattern=on 8pt off 7pt on 3pt off 8pt] (0,2.2) -- (0,2.8);
 %
 \draw[line width=4mm,line cap=round,green!20!black,Butt Cap-] (0,0) --
 (0,1.6);
 \draw[line width=4mm,green!80!black!70!blue,
 dash pattern=on 8pt off 7pt on 3pt off 8pt] (0,0) -- (0,1.4);
 %
 \draw[line width=4mm,line cap=round,red,Butt Cap-] (1,1.1) --
 (1,1.6);
 \draw[line width=4mm,orange] (1,1.1) -- (1,1.3);
 %
 \draw[line width=1.5mm,orange!50!yellow,rounded corners=5mm,-Triangle,
 postaction={decorate,decoration={markings, mark=at position \X with {%
 \coordinate (first);
 }}},shorten >=10mm] 
 (0,0) -- (0,-1.5) -- (4,-1.5) --  (4,1.8);
 %
 \draw[line width=1.5mm,orange!50!yellow,rounded corners=5mm,-Triangle,
 postaction={decorate,decoration={markings, mark=at position \X with {%
 \coordinate (second);
 }}},shorten >=5mm] 
 (1,1) -- (1,0) --  (3.14,0);
 %
 \begin{scope}[xshift=3cm]
  \draw[line width=4mm,line cap=round,green!20!black,Butt Cap-] (0,0) --
 (0,1.6);
 \draw[line width=4mm,green!80!black!70!blue,
 dash pattern=on 8pt off 7pt on 3pt off 8pt] (0,0) -- (0,1.4);
 %
 \draw[line width=4mm,line cap=round,red,Butt Cap-] (1,1.1) --
 (1,1.6);
 \draw[line width=4mm,orange] (1,1.1) -- (1,1.3);
 \end{scope}
 %
 \begin{scope}[shift={(first)}]
  \draw[line width=4mm,line cap=round,cyan,-Butt Cap] (0,-0.6) --
 (0,0);
 \draw[line width=4mm,orange] (0,-0.15) -- (0,0);
 \draw[line width=4mm,green!20!black] (0,-0.25) -- (0,-0.15);
 \end{scope}
 %
 \begin{scope}[shift={(second)}]
  \draw[line width=4mm,red,line cap=round,red,Butt Cap-] (0,0.1) -- (0,-1);
  \draw[line width=4mm,red!50!black,
  dash pattern=on 3pt off 7pt on 8pt off 5pt on 3pt] (0,0) -- (0,-0.9);
 \end{scope}
\end{tikzpicture}
}   
\end{document}

进而转换为

convert -density 300 -delay 24 -loop 0 -alpha remove multipage.pdf animated.gif

附录:投影机版本。

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,decorations.markings}
\newcount\myangle

\begin{document}
\transduration{2}
\animate<2-22>
\begin{frame}[t,fragile]{Protein}
\animatevalue<2-22>{\myangle}{0}{20}
\begin{tikzpicture}
 \pgfmathsetmacro{\X}{\myangle/21}
 %
 \path[use as bounding box](-0.2,-2) rectangle (4.2,3.1);
 \draw[line width=4mm,line cap=round,green!80!black!70!blue] (0,2) -- (0,3);
 \draw[line width=4mm,green!20!black,
 dash pattern=on 8pt off 7pt on 3pt off 8pt] (0,2.2) -- (0,2.8);
 %
 \draw[line width=4mm,line cap=round,green!20!black,Butt Cap-] (0,0) --
 (0,1.6);
 \draw[line width=4mm,green!80!black!70!blue,
 dash pattern=on 8pt off 7pt on 3pt off 8pt] (0,0) -- (0,1.4);
 %
 \draw[line width=4mm,line cap=round,red,Butt Cap-] (1,1.1) --
 (1,1.6);
 \draw[line width=4mm,orange] (1,1.1) -- (1,1.3);
 %
 \draw[line width=1.5mm,orange!50!yellow,rounded corners=5mm,-Triangle,
 postaction={decorate,decoration={markings, mark=at position \X with {%
 \coordinate (first);
 }}},shorten >=10mm] 
 (0,0) -- (0,-1.5) -- (4,-1.5) --  (4,1.8);
 %
 \draw[line width=1.5mm,orange!50!yellow,rounded corners=5mm,-Triangle,
 postaction={decorate,decoration={markings, mark=at position \X with {%
 \coordinate (second);
 }}},shorten >=5mm] 
 (1,1) -- (1,0) --  (3.14,0);
 %
 \begin{scope}[xshift=3cm]
  \draw[line width=4mm,line cap=round,green!20!black,Butt Cap-] (0,0) --
 (0,1.6);
 \draw[line width=4mm,green!80!black!70!blue,
 dash pattern=on 8pt off 7pt on 3pt off 8pt] (0,0) -- (0,1.4);
 %
 \draw[line width=4mm,line cap=round,red,Butt Cap-] (1,1.1) --
 (1,1.6);
 \draw[line width=4mm,orange] (1,1.1) -- (1,1.3);
 \end{scope}
 %
 \begin{scope}[shift={(first)}]
  \draw[line width=4mm,line cap=round,cyan,-Butt Cap] (0,-0.6) --
 (0,0);
 \draw[line width=4mm,orange] (0,-0.15) -- (0,0);
 \draw[line width=4mm,green!20!black] (0,-0.25) -- (0,-0.15);
 \end{scope}
 %
 \begin{scope}[shift={(second)}]
  \draw[line width=4mm,red,line cap=round,red,Butt Cap-] (0,0.1) -- (0,-1);
  \draw[line width=4mm,red!50!black,
  dash pattern=on 3pt off 7pt on 8pt off 5pt on 3pt] (0,0) -- (0,-0.9);
 \end{scope}
\end{tikzpicture}
\end{frame}   
\end{document}

相关内容