我想画一个核反应堆。texamples.net有一个模板,它几乎就是我想要做的。代码是
% Pressurized Water Reactor
% Author: Gloria Faccanoni <http://www.science.unitn.it/~gloria/home.htm>
%
\documentclass[a4paper,10pt,landscape]{article}
%\usepackage[latin1]{inputenc}
\usepackage[Gray]{SIunits}
\usepackage[dvipsnames,pdftex,fixpdftex]{xcolor}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage[hmargin=1cm,vmargin=1cm]{geometry}
\begin{document}
\centering
\begin{tikzpicture}[
scale=0.7,
annotline/.style = {stealth-},
arrows1loop/.style={->,red},
arrows2loop/.style={->,white},
arrows3loop/.style={->,draw=Gray},
]
\draw[draw=Gray,double=Gray!10,double distance=4pt]
(12,12) to[out=135,in=45](0,12)--(0,0)--(22,0)--(22,12)--(12,12)--(12,0);
\node[text width=4cm, text centered,font=\small] at (6,13)
{Containment\\structure};
% legend
\begin{scope}[yshift=-2cm]
\filldraw[draw=red,fill=red!10] (1,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (3,0.5)
{Pressurized water\\(primary loop)};
\filldraw[draw=blue,bottom color=blue!40,top color=Gray!30]
(11,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (13,0.5)
{Water and steam\\(secondary loop)};
\filldraw[draw=Blue,fill=Blue!10] (21,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (23,0.5)
{Water\\(cooling loop)};
\end{scope}
% 2nd loop --------------------------------------------------------------------
\begin{scope}[xshift=7.25cm,yshift=3cm]
% vessel left
\filldraw[draw=blue,bottom color=blue!40,top color=Gray!30]
(0,0) to[out=-20,in=200] (3.5,0) --
(3.5,4.5) to[out=120,in=60] (0,4.5) -- (0,0);
% vessel right
\filldraw[draw=blue,bottom color=blue!40,top color=Gray!30,xshift=7cm]
(0,0) to[out=-20,in=200] (3.5,0) --
(3.5,5) to[out=120,in=60] (0,5) -- (0,0);
% circuits
\draw[draw=blue,double=blue!40,double distance=4pt]
(1.75,-0.3) -- ++(0,-1) -- ++(7,0) -- ++(0,1);
\draw[draw=blue,double=Gray!30,double distance=4pt]
(1.75,5.38) -- ++(0,1) -- ++(4,0) -- ++(0,1) -- ++(3,0) -- ++(0,-1.5);
% arrows
\draw[arrows2loop] (3.5,-1.3) -- (3,-1.3);
\draw[arrows2loop] (1.75,-0.9) -- (1.75,-0.4);
\draw[arrows2loop] (4.5,6.38) -- (5,6.38);
\draw[arrows2loop] (7,7.38) -- (7.5,7.38);
\draw[arrows2loop] (8.75,6.4) -- (8.75,5.9);
\draw[arrows2loop] (8.75,-0.4) -- (8.75,-0.9);
%
\foreach \x in {0.5,1,...,3}
\draw[arrows2loop,xshift=7cm] (\x,3) -- (\x,2.5);
% labels
\draw[annotline] (2.5,-1.3) -- ++(3.5,1.3)
node[text width=1cm,font=\small,above] {Liquid};
\draw[annotline] (2.5,6.38) -- ++(3.5,-1.3)
node[text width=1cm,font=\small,below] {Vapor};
% pump
\begin{scope}[xshift=160,yshift=-40]
\filldraw[fill=Blue!20,draw=Blue] (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\filldraw[fill=Blue!40,draw=Blue,yshift=-0.5cm]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=Blue!40,draw=Blue,yshift=+0.5cm,rotate=180]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=Blue!40,draw=Blue,xshift=+0.5cm,rotate=90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=Blue!40,draw=Blue,xshift=-0.5cm,rotate=-90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\end{scope}
% generator ...
\draw[xshift=6.5cm,draw=Gray,double=Gray!10,double distance=4pt]
(3,4) -- ++(2,0);
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.8,4) -- (3.0,3.3) -- (3.0,4.7) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.5,4) -- (2.5,3.4) -- (2.5,4.6) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.2,4) -- (2 ,3.5) -- (2 ,4.5) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(4.5,3.3) rectangle (7.3,4.7);
%labels
\node[text width=3cm, text centered,font=\small] at (1.75,4)
{Steam generator\\ (heat change)};
\node[text width=2cm, text centered,font=\small] at (8.8,5) {Turbine};
\node[text width=2cm, text centered,font=\small] at (12.4,4) {Alternator};
% transmission lines
\node (aa) at (11.1,4.6) {};
\node (bb) at (11.6,4.6) {};
\node (cc) at (12.1,4.6) {};
\node (dd) at (12.6,4.6) {};
\node (ee) at (13.1,4.6) {};
\node (ff) at (13.6,4.6) {};
\end{scope}
% 3 loop --------------------------------------------------------------------
\begin{scope}[xshift=23cm,yshift=1cm]
% circuit
\draw[draw=Blue,double=Blue!10,double distance=4pt]
(1,2.5) -- ++(-8.5,0) -- ++(0,+1.5) -- ++(8.5,0);
% arrows
\draw[arrows3loop] (-5.5,2.5) -- (-6,2.5);
\draw[arrows3loop] (-1.5,2.5) -- (-2,2.5);
\draw[arrows3loop] (-6,4) -- (-5.5,4);
\draw[arrows3loop] (-2,4) -- (-1.5,4);
% tower
\filldraw[draw=Gray,fill=Gray!20] (1,7) to[out=270,in=80]
(0,0) to[out=-20,in=200]
(6,0) to[out=100,in=270]
(5,7);
\filldraw[draw=Gray,fill=Gray!40] (1,7) to[out=30,in=150]
(5,7) to[out=200,in=-20]
(1,7);
% labels
\node[text width=3cm, text centered,font=\small] at (3,3.5)
{Cooling\\tower};
\node[text width=2cm, text centered,font=\small] at (-3.5,1.5)
{Cooling\\water};
\node[text width=2cm, text centered,font=\small] at (-6,3.25)
{Condenser};
% pump
\begin{scope}[xshift=-10,yshift=115]
\filldraw[fill=purple!20,draw=purple] (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\filldraw[fill=purple!40,draw=purple,yshift=-0.5cm]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=purple!40,draw=purple,yshift=+0.5cm,rotate=180]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=purple!40,draw=purple,xshift=+0.5cm,rotate=90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=purple!40,draw=purple,xshift=-0.5cm,rotate=-90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\end{scope}
\end{scope}
%1 loop --------------------------------------------------------------------
\begin{scope}[xshift=2cm,yshift=4cm]
% Reactor vessel
\filldraw[draw=red,fill=red!10] (0,-0.5) to[out=-20,in=200]
(3.5,-0.5) --
(3.5,4.5) to[out=160,in=20]
(0,4.5) --
(0,-0.5);
% circuit
\draw[draw=red,double=red!10,double distance=4pt]
(0.1,1) -- ++(-1,0) -- ++(0,-3) -- ++(5,0) -- ++(0,1.5) --
++(3,0) -- ++(0,2) -- ++(-3.7,0);
% Pressurizer
\draw[draw=red,double=red!10,double distance=4pt] (4.2,1.6) -- ++(0,0.8);
\filldraw[draw=Green,bottom color=red!40,top color=Green!20]
(4,2.4) to[out=-20,in=200]
(4.5,2.4) --
(4.5,3.6) to[out=160,in=20]
(3.9,3.6) --
(3.9,2.4);
% arrows
\draw[arrows1loop] (-0.7,1) -- (-0.2,1);
\draw[arrows1loop] (-0.9,-0.5) -- (-0.9,0);
\draw[arrows1loop] (0.7,-2) -- (0.2,-2);
\draw[arrows1loop] (4.5,1.5) -- (5,1.5);
\draw[arrows1loop] (7.1,0.5) -- (7.1,0);
\draw[arrows1loop] (5.5,-0.5) -- (5,-0.5);
% pump
\begin{scope}[xshift=75,yshift=-55,fill=red!20,draw=red]
\filldraw (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\filldraw[yshift=-0.5cm] (0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[yshift=+0.5cm,rotate=180]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[xshift=+0.5cm,rotate=90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[xshift=-0.5cm,rotate=-90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\end{scope}
% reactor core
\filldraw[fill=red!30,draw=red] (0.7,0) rectangle (2.8,2);
% control rods
\foreach \x in {1.0,1.5,2.0,2.5}
\draw[draw=Gray,double=Gray!50,double distance=0.5pt] (\x,0.3) -- (\x,3.7);
%labels
\draw[annotline] (0.6,0.5) -- ++(-3.3,-1.5)
node[text width=1cm,font=\small,left] {Reactor core};
\node[text width=2cm, text centered,font=\small] at (1.75,5.4) {Reactor vessel};
\draw[annotline] (0.9,2.8) -- ++(-3.3,1.5)
node[text width=2cm, text centered,font=\small,left=-8pt] {Control\\rods};
\draw[annotline] (4.2,3.7) -- ++(0.5,1.5)
node[text width=2cm, text centered,font=\small,above] {Pressurizer};
\draw[annotline] (3.9,1.5) -- ++(1.3,-0.6)
node[text width=2.4cm, text centered,below=-2pt,font=\small]
{Water coolant (\unit{330}{\degreecelsius})};
\draw[annotline] (-0.1,-2) -- ++(-0.3,-0.6)
node[text width=2.4cm, text centered,below=-2pt,font=\small]
{Water coolant (\unit{280}{\degreecelsius})};
\end{scope}
% clouds ----------------------------------
\begin{scope}[xshift=26cm,yshift=10cm, fill=blue!10, draw=Blue,
decoration={bumps,segment length=0.5cm}]
\filldraw[yshift=-1.5cm,rotate=-25,decorate]
(0,0) -- ++(-0.4,1.25)-- ++(-0.1,0.75)-- ++(0.2,0.5)-- ++(0.3,0.5)--
++(0.3,-0.5)-- ++(0.2,-0.5)-- ++(-0.1,-0.75)-- ++(-0.4,-1.25);
\filldraw[xshift=0.5cm,yshift=-2cm,rotate=-30,decorate]
(0,0) -- ++(-0.4,1.25)-- ++(-0.1,0.75)-- ++(0.2,0.5)-- ++(0.3,0.5)--
++(0.3,-0.5)-- ++(0.2,-0.5)-- ++(-0.1,-0.75)-- ++(-0.4,-1.25);
\filldraw[xshift=-1.05cm,yshift=-2.15cm,rotate=-20,decorate]
(0,0) -- ++(-0.4,1.25)-- ++(-0.1,0.75)-- ++(0.2,0.5)-- ++(0.3,0.5)--
++(0.3,-0.5)-- ++(0.2,-0.5)-- ++(-0.1,-0.75)-- ++(-0.4,-1.25);
%labels
\node[text width=1cm, text centered,font=\small] at (0.2,1.5) {Water vapor};
\end{scope}
% palo della luce
\begin{scope}[xscale=0.2,xshift=113cm,yshift=19cm,line width=1pt,Brown]
\draw (0,0) -- (-6,-6)
(0,0) -- ( 6,-6)
(-1,-1) -- ( 1,-1)
(-1,-1) -- ( 2,-2)
( 1,-1) -- (-2,-2)
(-2,-2) -- ( 2,-2)
(-2,-2) -- ( 3,-3)
( 2,-2) -- (-3,-3)
( 3,-3) -- (-3,-3)
(-3,-3) -- ( 4,-4)
( 3,-3) -- (-4,-4)
( 4,-4) -- (-4,-4)
(-4,-4) -- ( 5,-5)
( 4,-4) -- (-5,-5)
( 5,-5) -- (-5,-5)
(-6,-6) -- ( 0,-5.2)
( 6,-6) -- ( 0,-5.2);
\draw (-1.5,-1.5) -- (-4,-1.5) -- (-1,-1)
( 1.5,-1.5) -- ( 4,-1.5) -- ( 1,-1);
\path (-4,-1.4) node (a) {}
( 4,-1.4) node (b) {};
\draw[line width=1pt,Brown] (-3.5,-3.5) -- (-7.5,-3.5) -- (-3,-3)
( 3.5,-3.5) -- ( 7.5,-3.5) -- ( 3,-3);
\path (-7.5,-3.4) node (c) {}
( 7.5,-3.4) node (d) {}
(-5.5,-3.4) node (e) {}
( 5.5,-3.4) node (f) {};
\end{scope}
% transmission lines
\draw[dashed,Gray] (c) -- (aa)
(a) -- (bb)
(e) -- (cc)
(b) -- (dd)
(f) -- (ee)
(d) -- (ff);
\end{tikzpicture}
\end{document}
输出为
在维基百科有一个类似的图像,其中有移动的泵、移动的流量等等。
如何使用来实现tikz
?
答案1
只是一个概念证明;流动是用一条非常粗的dashed
线创建的,具有特定的dash pattern
;在偶数和奇数幻灯片中使用不同的值获得了运动的错觉dash phase
(感谢杰克对于这个建议简化了我的初始代码):
\documentclass{beamer}
\usepackage{tikz}
\def\phase{0pt}
\begin{document}
\begin{frame}
\centering
\begin{tikzpicture}
\draw[orange,double=orange!60,double distance=14pt,rounded corners] (0,0) |- (6,3) -- (6,0) -- cycle;
\onslide<1-10>{
\ifodd\thepage\relax\def\phase{8pt}\fi
\draw[rounded corners,line width=8pt,dashed,blue!80!black,dash pattern={on 12pt off 6pt},dash phase=\phase] (0,0) |- (6,3) -- (6,0) -- cycle;
}
\end{tikzpicture}
\end{frame}
\end{document}
动画是使用ImageMagick
和制作的
convert -verbose -delay 50 -loop 0 -density 300 <file>.pdf <file>.gif
现在,我们将这个想法融入了反应器的实际代码中;这个想法与上面的示例代码相同:一个十张幻灯片的beamer
文档;\thepage
计数器用于改变各种元素,并在创建动画时产生运动的幻觉。流程使用简单的样式生成:
\tikzset{
flow/.style={rounded corners,line width=1.5pt,line cap=round,dashed,draw=#1,dash pattern={on 5pt off 5pt},dash phase=\thepage}
}
代码:
% Pressurized Water Reactor
% Author: Gloria Faccanoni <http://www.science.unitn.it/~gloria/home.htm>
%
\PassOptionsToPackage{dvipsnames,pdftex,fixpdftex}{xcolor}
\documentclass{beamer}
%\usepackage[latin1]{inputenc}
\usepackage[Gray]{SIunits}
\let\square\relax
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\def\phase{0pt}
\def\altshift{0pt}
\def\bcolor{white!30!black}
\tikzset{
flow/.style={rounded corners,line width=1.5pt,line cap=round,dashed,draw=#1,dash pattern={on 5pt off 5pt},dash phase=\thepage}
}
\begin{document}
\begin{frame}
\centering
\begin{tikzpicture}[
scale=0.35,transform shape,
annotline/.style = {stealth-},
arrows2loop/.style={->,white},
]
\draw[draw=Gray,double=Gray!10,double distance=4pt]
(12,12) to[out=135,in=45](0,12)--(0,0)--(22,0)--(22,12)--(12,12)--(12,0);
\node[text width=4cm, text centered,font=\small] at (6,13)
{Containment\\structure};
% legend
\begin{scope}[yshift=-2cm]
\filldraw[draw=red,fill=red!10] (1,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (3,0.5)
{Pressurized water\\(primary loop)};
\filldraw[draw=blue,bottom color=blue!40,top color=Gray!30]
(11,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (13,0.5)
{Water and steam\\(secondary loop)};
\filldraw[draw=Blue,fill=Blue!10] (21,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (23,0.5)
{Water\\(cooling loop)};
\end{scope}
% 2nd loop --------------------------------------------------------------------
\begin{scope}[xshift=7.25cm,yshift=3cm]
% vessel left
\filldraw[draw=blue,bottom color=blue!40,top color=Gray!30]
(0,0) to[out=-20,in=200] (3.5,0) --
(3.5,4.5) to[out=120,in=60] (0,4.5) -- (0,0);
% vessel right
\filldraw[draw=blue,bottom color=blue!40,top color=Gray!30,xshift=7cm]
(0,0) to[out=-20,in=200] (3.5,0) --
(3.5,5) to[out=120,in=60] (0,5) -- (0,0);
% circuits
\draw[draw=blue,double=blue!40,double distance=4pt]
(1.75,-0.3) -- ++(0,-1) -- ++(7,0) -- ++(0,1);
\draw[draw=blue,double=Gray!30,double distance=4pt]
(1.75,5.38) -- ++(0,1) -- ++(4,0) -- ++(0,1) -- ++(3,0) -- ++(0,-1.5);
% arrows
\draw[arrows2loop] (3.5,-1.3) -- (3,-1.3);
\draw[arrows2loop] (1.75,-0.9) -- (1.75,-0.4);
\draw[arrows2loop] (4.5,6.38) -- (5,6.38);
\draw[arrows2loop] (7,7.38) -- (7.5,7.38);
\draw[arrows2loop] (8.75,6.4) -- (8.75,5.9);
\draw[arrows2loop] (8.75,-0.4) -- (8.75,-0.9);
%
\foreach \x in {0.5,1,...,3}
\draw[arrows2loop,xshift=7cm] (\x,3) -- (\x,2.5);
% labels
\draw[annotline] (2.5,-1.3) -- ++(3.5,1.3)
node[text width=1cm,font=\small,above] {Liquid};
\draw[annotline] (2.5,6.38) -- ++(3.5,-1.3)
node[text width=1cm,font=\small,below] {Vapor};
% pump
\begin{scope}[xshift=160,yshift=-40]
\filldraw[fill=Blue!20,draw=Blue] (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\onslide<1-10>{
\draw[Blue] (185+36*\thepage:0.5) -- (5+36*\thepage:0.5);
\draw[Blue] (95+36*\thepage:0.5) -- (275+36*\thepage:0.5);
}
\end{scope}
\onslide<1-10>{
\draw[flow=blue,dash phase=\thepage]
(0.5,2) -- (0.5,1) -| (1.5,0.3) -- (1.75,-0.3) -- ++(0,-1) -- ++(7,0) -- ++(0,1);
\draw[flow=blue]
(3,2) -- (3,1) -| (2,0.3) -- (1.75,-0.3);
}
% generator ...
\draw[xshift=6.5cm,draw=Gray,double=Gray!10,double distance=4pt]
(3,4) -- ++(2,0);
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.8,4) -- (3.0,3.3) -- (3.0,4.7) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.5,4) -- (2.5,3.4) -- (2.5,4.6) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.2,4) -- (2 ,3.5) -- (2 ,4.5) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(4.5,3.5) rectangle (7.3,4.5);
\coordinate[xshift=6.5cm] (alta) at (7.3,4.5);
\coordinate[xshift=6.5cm] (altb) at (7.3,3.5);
\onslide<1-10>{
\ifodd\thepage\relax\else\def\altshift{-3pt}\fi
\draw[orange,xshift=6.5cm,yshift=-7pt+\altshift] (4.5,4.6) -- (7.3,4.6);
\draw[orange,xshift=6.5cm,yshift=-15pt+\altshift] (4.5,4.6) -- (7.3,4.6);
\draw[orange,xshift=6.5cm,yshift=-23pt+\altshift] (4.5,4.6) -- (7.3,4.6);
}
%labels
\node[text width=3cm, text centered,font=\small] at (1.75,4)
{Steam generator\\ (heat change)};
\node[text width=2cm, text centered,font=\small] at (8.8,5) {Turbine};
\node[text width=2cm, text centered,font=\small] at (12.4,4) {Alternator};
% transmission lines
\node (aa) at (11.1,4.6) {};
\node (bb) at (11.6,4.6) {};
\node (cc) at (12.1,4.6) {};
\node (dd) at (12.6,4.6) {};
\node (ee) at (13.1,4.6) {};
\node (ff) at (13.6,4.6) {};
\end{scope}
% 3 loop --------------------------------------------------------------------
\begin{scope}[xshift=23cm,yshift=1cm]
% circuit
\draw[draw=Blue,double=Blue!10,double distance=4pt]
(1,2.5) -- ++(-8.5,0) -- ++(0,+1.5) -- ++(8.5,0);
% labels
\node[text width=2cm, text centered,font=\small] at (-3.5,1.5)
{Cooling\\water};
\node[text width=2cm, text centered,font=\small] at (-6,3.25)
{Condenser};
% pump
\begin{scope}[xshift=-10,yshift=115]
\filldraw[fill=Blue!20,draw=Blue] (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\onslide<1-10>{
\draw[Blue] (185+36*\thepage:0.5) -- (5+36*\thepage:0.5);
\draw[Blue] (95+36*\thepage:0.5) -- (275+36*\thepage:0.5);
}
\end{scope}
\onslide<1-10>{
\draw[flow=Blue!70] (1,2.5) -- ++(-8.5,0) -- ++(0,+1.5) -- ++(8.5,0);
}
% tower
\filldraw[draw=Gray,fill=Gray!20] (1,7) to[out=270,in=80]
(0,0) to[out=-20,in=200]
(6,0) to[out=100,in=270]
(5,7);
\filldraw[draw=Gray,fill=Gray!40] (1,7) to[out=30,in=150]
(5,7) to[out=200,in=-20]
(1,7);
% labels
\node[text width=3cm, text centered,font=\small] at (3,3.5)
{Cooling\\tower};
\end{scope}
%1 loop --------------------------------------------------------------------
\begin{scope}[xshift=2cm,yshift=4cm]
% Reactor vessel
\filldraw[draw=red,fill=red!10] (0,-0.5) to[out=-20,in=200]
(3.5,-0.5) --
(3.5,4.5) to[out=160,in=20]
(0,4.5) --
(0,-0.5);
% circuit
\draw[draw=red,double=red!10,double distance=4pt]
(0.1,1) -- ++(-1,0) -- ++(0,-3) -- ++(5,0) -- ++(0,1.5) --
++(3,0) -- ++(0,2) -- ++(-3.7,0);
% Pressurizer
\draw[draw=red,double=red!10,double distance=4pt] (4.2,1.6) -- ++(0,0.8);
\filldraw[draw=Green,bottom color=red!40,top color=Green!20]
(4,2.4) to[out=-20,in=200]
(4.5,2.4) --
(4.5,3.6) to[out=160,in=20]
(3.9,3.6) --
(3.9,2.4);
% pump
\begin{scope}[xshift=75,yshift=-55,fill=red!20,draw=red]
\filldraw (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\onslide<1-10>{
\draw[red] (185+36*\thepage:0.5) -- (5+36*\thepage:0.5);
\draw[red] (95+36*\thepage:0.5) -- (275+36*\thepage:0.5);
}
\end{scope}
% reactor core
\filldraw[fill=red!30,draw=red] (0.7,0) rectangle (2.8,2);
% control rods
\foreach \x in {1.0,1.5,2.0,2.5}
\draw[draw=Gray,double=Gray!50,double distance=0.5pt] (\x,0.3) -- (\x,3.7);
\onslide<1-10>{
\draw[flow=red]
(0.1,1) -- ++(-1,0) -- ++(0,-3) -- ++(5,0) -- ++(0,1.5) --
++(3,0) -- ++(0,2) -- ++(-4,0) -- ++(0,2.5) -- ++(-0.8,0) -- ++(0,-4.3) --
++(-0.55,0) -- ++(0,4.3) -- ++(-0.55,0) -- ++(0,-4.3) --
++(-0.7,0) -- ++(0,1.3) -- ++(-0.15,0);
}
%labels
\draw[annotline] (0.6,0.5) -- ++(-3.3,-1.5)
node[text width=1cm,font=\small,left] {Reactor core};
\node[text width=2cm, text centered,font=\small] at (1.75,5.4) {Reactor vessel};
\draw[annotline] (0.9,2.8) -- ++(-3.3,1.5)
node[text width=2cm, text centered,font=\small,left=-8pt] {Control\\rods};
\draw[annotline] (4.2,3.7) -- ++(0.5,1.5)
node[text width=2cm, text centered,font=\small,above] {Pressurizer};
\draw[annotline] (3.9,1.5) -- ++(1.3,-0.6)
node[text width=2.4cm, text centered,below=-2pt,font=\small]
{Water coolant (\unit{330}{\degreecelsius})};
\draw[annotline] (-0.1,-2) -- ++(-0.3,-0.6)
node[text width=2.4cm, text centered,below=-2pt,font=\small]
{Water coolant (\unit{280}{\degreecelsius})};
\end{scope}
% palo della luce
\begin{scope}[xscale=0.2,xshift=128cm,yshift=16cm,line width=1pt,Brown]
\draw (0,0) -- (-6,-6)
(0,0) -- ( 6,-6)
(-1,-1) -- ( 1,-1)
(-1,-1) -- ( 2,-2)
( 1,-1) -- (-2,-2)
(-2,-2) -- ( 2,-2)
(-2,-2) -- ( 3,-3)
( 2,-2) -- (-3,-3)
( 3,-3) -- (-3,-3)
(-3,-3) -- ( 4,-4)
( 3,-3) -- (-4,-4)
( 4,-4) -- (-4,-4)
(-4,-4) -- ( 5,-5)
( 4,-4) -- (-5,-5)
( 5,-5) -- (-5,-5)
(-6,-6) -- ( 0,-5.2)
( 6,-6) -- ( 0,-5.2);
\draw (-1.5,-1.5) -- (-4,-1.5) -- (-1,-1)
( 1.5,-1.5) -- ( 4,-1.5) -- ( 1,-1);
\path (-4,-1.4) node (a) {}
( 4,-1.4) node (b) {};
\path (-7.5,-3.4) node (c) {}
( 7.5,-3.4) node (d) {}
(-5.5,-3.4) node (e) {}
( 5.5,-3.4) node (f) {};
\end{scope}
% transmission lines (alternator-tower)
\draw[Gray]
(alta) to[out=30,in=260] (a)
(altb) to[out=30,in=260] (b);
% building
\begin{scope}[xscale=0.2,xshift=100cm,yshift=17cm]
\filldraw (-3.5,0) rectangle (0.6,2);
\onslide<1-10>{
\ifnum\thepage<7\relax
\else
\ifnum\thepage=7\relax
\def\bcolor{white!50!black}
\else\ifnum\thepage=8\relax
\def\bcolor{white!80!black}
\else\ifnum\thepage<11\relax
\def\bcolor{white!97!black}
\fi\fi\fi\fi
\foreach \piso in {0.1,0.5,...,1.7}
{
\filldraw[\bcolor] (-3.05,\piso) rectangle (-2,\piso+0.2);
\filldraw[\bcolor] (-1.15,\piso) rectangle (0.1,\piso+0.2);
}
}
% transmission lines (tower-building)
\draw[Gray]
(a) to[out=185,in=-20] (-0.7,0)
(b) to[out=182,in=-20] (0.6,0);
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}
答案2
我利用你的问题最终尝试了动画包。“动画”位于外部文件中,它使用独立包装和markings
装饰蒂克兹:
“动画”代码
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\tikzset{reddot/.style={decoration={markings, mark=between positions #1 and 1 step 0.01 with {\fill[red] circle(0.05);}}}}
\foreach \x in {0,1,...,9}
{ \begin{tikzpicture}
\filldraw[yellow!10,draw=yellow!50!black] (-1,-7) rectangle node[yellow!50!black] {reactor} (7,3);
\draw[reddot=\x/1000,postaction={decorate}] (0,0) -- (4,0) -- (6,2) -- (6,-4) arc (360:180:2) -- (0,-3) -- cycle;
\end{tikzpicture}
}
\end{document}
然后我使用这个由 PDF 文件中的 10 个单页组成的“动画”(动画.pdf)将其放入真实文档中:
文档代码
\documentclass{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{lipsum}
\usepackage{animate}
\begin{document}
\lipsum[1-2]
\begin{center}
\begin{figure}[htp]
\animategraphics[autoplay,loop]{10}{anim}{}{}
\caption{reactor cycle}
\end{figure}
\end{center}
\lipsum[3-4]
\end{document}
输出
(这是用图像魔术师,因为无法上传 PDF)
编辑1:编辑给定的代码非常容易,我这样做是为了循环 1,反应堆循环。要动画的路径标记为电路。我所做的就是:
- 复制电路代码,一次用于管道,一次用于流量(也可以只使用一个并将流量添加为
postaction
) - 添加一点
rounded corners
让它看起来更漂亮 - 注释掉所有箭头
- 我决定使用 10 张图片,因此我
foreach
在图片外面添加了一个循环 - 改变班级为独立
- 摆脱了大写的颜色(例如
Green
),因为我得到了一个软件包选项冲突为了彩色 - 被取代国际单位制和希尼奇
- 用过的文本压缩摄氏度符号(也可以使用例如
\SI{42}{\celsius}
) - 使用了 Jake 的建议
我dash pattern
使用的 长度为 6pt(4pt 开 + 2pt 关),因此我将 设置dash phase
为\x/10*6pt
。这样,虚线将移动0%,10%,...,90%
一个周期,使动画更加流畅。
“动画”代码
% Pressurized Water Reactor
% Author: Gloria Faccanoni <http://www.science.unitn.it/~gloria/home.htm>
%
\documentclass[tikz]{standalone}
\usepackage{siunitx}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{textcomp}
\begin{document}
\foreach \x in {0,...,9}
{
\begin{tikzpicture}[
scale=0.7,
annotline/.style = {stealth-},
arrows1loop/.style={->,red},
arrows2loop/.style={->,white},
arrows3loop/.style={->,draw=gray},
]
\draw[draw=gray,double=gray!10,double distance=4pt]
(12,12) to[out=135,in=45](0,12)--(0,0)--(22,0)--(22,12)--(12,12)--(12,0);
\node[text width=4cm, text centered,font=\small] at (6,13)
{Containment\\structure};
% legend
\begin{scope}[yshift=-2cm]
\filldraw[draw=red,fill=red!10] (1,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (3,0.5)
{Pressurized water\\(primary loop)};
\filldraw[draw=blue,bottom color=blue!40,top color=gray!30]
(11,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (13,0.5)
{Water and steam\\(secondary loop)};
\filldraw[draw=blue,fill=blue!10] (21,0) rectangle ++(2,1);
\node[text width=4cm, font=\small,right] at (23,0.5)
{Water\\(cooling loop)};
\end{scope}
% 2nd loop --------------------------------------------------------------------
\begin{scope}[xshift=7.25cm,yshift=3cm]
% vessel left
\filldraw[draw=blue,bottom color=blue!40,top color=gray!30]
(0,0) to[out=-20,in=200] (3.5,0) --
(3.5,4.5) to[out=120,in=60] (0,4.5) -- (0,0);
% vessel right
\filldraw[draw=blue,bottom color=blue!40,top color=gray!30,xshift=7cm]
(0,0) to[out=-20,in=200] (3.5,0) --
(3.5,5) to[out=120,in=60] (0,5) -- (0,0);
% circuits
\draw[draw=blue,double=blue!40,double distance=4pt]
(1.75,-0.3) -- ++(0,-1) -- ++(7,0) -- ++(0,1);
\draw[draw=blue,double=gray!30,double distance=4pt]
(1.75,5.38) -- ++(0,1) -- ++(4,0) -- ++(0,1) -- ++(3,0) -- ++(0,-1.5);
% arrows
\draw[arrows2loop] (3.5,-1.3) -- (3,-1.3);
\draw[arrows2loop] (1.75,-0.9) -- (1.75,-0.4);
\draw[arrows2loop] (4.5,6.38) -- (5,6.38);
\draw[arrows2loop] (7,7.38) -- (7.5,7.38);
\draw[arrows2loop] (8.75,6.4) -- (8.75,5.9);
\draw[arrows2loop] (8.75,-0.4) -- (8.75,-0.9);
%
\foreach \x in {0.5,1,...,3}
\draw[arrows2loop,xshift=7cm] (\x,3) -- (\x,2.5);
% labels
\draw[annotline] (2.5,-1.3) -- ++(3.5,1.3)
node[text width=1cm,font=\small,above] {Liquid};
\draw[annotline] (2.5,6.38) -- ++(3.5,-1.3)
node[text width=1cm,font=\small,below] {Vapor};
% pump
\begin{scope}[xshift=160,yshift=-40]
\filldraw[fill=blue!20,draw=blue] (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\filldraw[fill=blue!40,draw=blue,yshift=-0.5cm]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=blue!40,draw=blue,yshift=+0.5cm,rotate=180]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=blue!40,draw=blue,xshift=+0.5cm,rotate=90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=blue!40,draw=blue,xshift=-0.5cm,rotate=-90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\end{scope}
% generator ...
\draw[xshift=6.5cm,draw=gray,double=gray!10,double distance=4pt]
(3,4) -- ++(2,0);
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.8,4) -- (3.0,3.3) -- (3.0,4.7) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.5,4) -- (2.5,3.4) -- (2.5,4.6) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(1.2,4) -- (2 ,3.5) -- (2 ,4.5) -- cycle;
\filldraw[xshift=6.5cm,fill=orange!10,draw=orange]
(4.5,3.3) rectangle (7.3,4.7);
%labels
\node[text width=3cm, text centered,font=\small] at (1.75,4)
{Steam generator\\ (heat change)};
\node[text width=2cm, text centered,font=\small] at (8.8,5) {Turbine};
\node[text width=2cm, text centered,font=\small] at (12.4,4) {Alternator};
% transmission lines
\node (aa) at (11.1,4.6) {};
\node (bb) at (11.6,4.6) {};
\node (cc) at (12.1,4.6) {};
\node (dd) at (12.6,4.6) {};
\node (ee) at (13.1,4.6) {};
\node (ff) at (13.6,4.6) {};
\end{scope}
% 3 loop --------------------------------------------------------------------
\begin{scope}[xshift=23cm,yshift=1cm]
% circuit
\draw[draw=blue,double=blue!10,double distance=4pt]
(1,2.5) -- ++(-8.5,0) -- ++(0,+1.5) -- ++(8.5,0);
% arrows
\draw[arrows3loop] (-5.5,2.5) -- (-6,2.5);
\draw[arrows3loop] (-1.5,2.5) -- (-2,2.5);
\draw[arrows3loop] (-6,4) -- (-5.5,4);
\draw[arrows3loop] (-2,4) -- (-1.5,4);
% tower
\filldraw[draw=gray,fill=gray!20] (1,7) to[out=270,in=80]
(0,0) to[out=-20,in=200]
(6,0) to[out=100,in=270]
(5,7);
\filldraw[draw=gray,fill=gray!40] (1,7) to[out=30,in=150]
(5,7) to[out=200,in=-20]
(1,7);
% labels
\node[text width=3cm, text centered,font=\small] at (3,3.5)
{Cooling\\tower};
\node[text width=2cm, text centered,font=\small] at (-3.5,1.5)
{Cooling\\water};
\node[text width=2cm, text centered,font=\small] at (-6,3.25)
{Condenser};
% pump
\begin{scope}[xshift=-10,yshift=115]
\filldraw[fill=purple!20,draw=purple] (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\filldraw[fill=purple!40,draw=purple,yshift=-0.5cm]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=purple!40,draw=purple,yshift=+0.5cm,rotate=180]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=purple!40,draw=purple,xshift=+0.5cm,rotate=90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[fill=purple!40,draw=purple,xshift=-0.5cm,rotate=-90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\end{scope}
\end{scope}
%1 loop --------------------------------------------------------------------
\begin{scope}[xshift=2cm,yshift=4cm]
% Reactor vessel
\filldraw[draw=red,fill=red!10] (0,-0.5) to[out=-20,in=200]
(3.5,-0.5) --
(3.5,4.5) to[out=160,in=20]
(0,4.5) --
(0,-0.5);
% === circuit =========
\draw[draw=red,double=red!10,double distance=4pt,rounded corners=2pt]
(0.1,1) -- ++(-1,0) -- ++(0,-3) -- ++(5,0) -- ++(0,1.5) --
++(3,0) -- ++(0,2) -- ++(-3.7,0);
\draw [line width=2pt, dash pattern=on 4pt off 2pt,dash phase=\x/10*6pt,red!80,rounded corners=2pt] (0.1,1) -- ++(-1,0) -- ++(0,-3) -- ++(5,0) -- ++(0,1.5) -- ++(3,0) -- ++(0,2) -- ++(-3.7,0);
% === =========
% Pressurizer
\draw[draw=red,double=red!10,double distance=4pt] (4.2,1.6) -- ++(0,0.8);
\filldraw[draw=green,bottom color=red!40,top color=green!20]
(4,2.4) to[out=-20,in=200]
(4.5,2.4) --
(4.5,3.6) to[out=160,in=20]
(3.9,3.6) --
(3.9,2.4);
% === arrows =========
%\draw[arrows1loop] (-0.7,1) -- (-0.2,1);
%\draw[arrows1loop] (-0.9,-0.5) -- (-0.9,0);
%\draw[arrows1loop] (0.7,-2) -- (0.2,-2);
%\draw[arrows1loop] (4.5,1.5) -- (5,1.5);
%\draw[arrows1loop] (7.1,0.5) -- (7.1,0);
%\draw[arrows1loop] (5.5,-0.5) -- (5,-0.5);
% === =========
% pump
\begin{scope}[xshift=75,yshift=-55,fill=red!20,draw=red]
\filldraw (0,0) circle (0.5cm);
\node[below,font=\small] at (0,-0.5) {Pump};
\filldraw[yshift=-0.5cm] (0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[yshift=+0.5cm,rotate=180]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[xshift=+0.5cm,rotate=90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\filldraw[xshift=-0.5cm,rotate=-90]
(0,0) arc (240:180:0.4cm) arc (200:280:0.4cm) ;
\end{scope}
% reactor core
\filldraw[fill=red!30,draw=red] (0.7,0) rectangle (2.8,2);
% control rods
\foreach \x in {1.0,1.5,2.0,2.5}
\draw[draw=gray,double=gray!50,double distance=0.5pt] (\x,0.3) -- (\x,3.7);
%labels
\draw[annotline] (0.6,0.5) -- ++(-3.3,-1.5)
node[text width=1cm,font=\small,left] {Reactor core};
\node[text width=2cm, text centered,font=\small] at (1.75,5.4) {Reactor vessel};
\draw[annotline] (0.9,2.8) -- ++(-3.3,1.5)
node[text width=2cm, text centered,font=\small,left=-8pt] {Control\\rods};
\draw[annotline] (4.2,3.7) -- ++(0.5,1.5)
node[text width=2cm, text centered,font=\small,above] {Pressurizer};
\draw[annotline] (3.9,1.5) -- ++(1.3,-0.6)
node[text width=2.4cm, text centered,below=-2pt,font=\small]
{Water coolant (\num{330}{\textdegree})};
\draw[annotline] (-0.1,-2) -- ++(-0.3,-0.6)
node[text width=2.4cm, text centered,below=-2pt,font=\small]
{Water coolant (\num{280}{\textdegree})};
\end{scope}
% clouds ----------------------------------
\begin{scope}[xshift=26cm,yshift=10cm, fill=blue!10, draw=blue,
decoration={bumps,segment length=0.5cm}]
\filldraw[yshift=-1.5cm,rotate=-25,decorate]
(0,0) -- ++(-0.4,1.25)-- ++(-0.1,0.75)-- ++(0.2,0.5)-- ++(0.3,0.5)--
++(0.3,-0.5)-- ++(0.2,-0.5)-- ++(-0.1,-0.75)-- ++(-0.4,-1.25);
\filldraw[xshift=0.5cm,yshift=-2cm,rotate=-30,decorate]
(0,0) -- ++(-0.4,1.25)-- ++(-0.1,0.75)-- ++(0.2,0.5)-- ++(0.3,0.5)--
++(0.3,-0.5)-- ++(0.2,-0.5)-- ++(-0.1,-0.75)-- ++(-0.4,-1.25);
\filldraw[xshift=-1.05cm,yshift=-2.15cm,rotate=-20,decorate]
(0,0) -- ++(-0.4,1.25)-- ++(-0.1,0.75)-- ++(0.2,0.5)-- ++(0.3,0.5)--
++(0.3,-0.5)-- ++(0.2,-0.5)-- ++(-0.1,-0.75)-- ++(-0.4,-1.25);
%labels
\node[text width=1cm, text centered,font=\small] at (0.2,1.5) {Water vapor};
\end{scope}
% palo della luce
\begin{scope}[xscale=0.2,xshift=113cm,yshift=19cm,line width=1pt,brown]
\draw (0,0) -- (-6,-6)
(0,0) -- ( 6,-6)
(-1,-1) -- ( 1,-1)
(-1,-1) -- ( 2,-2)
( 1,-1) -- (-2,-2)
(-2,-2) -- ( 2,-2)
(-2,-2) -- ( 3,-3)
( 2,-2) -- (-3,-3)
( 3,-3) -- (-3,-3)
(-3,-3) -- ( 4,-4)
( 3,-3) -- (-4,-4)
( 4,-4) -- (-4,-4)
(-4,-4) -- ( 5,-5)
( 4,-4) -- (-5,-5)
( 5,-5) -- (-5,-5)
(-6,-6) -- ( 0,-5.2)
( 6,-6) -- ( 0,-5.2);
\draw (-1.5,-1.5) -- (-4,-1.5) -- (-1,-1)
( 1.5,-1.5) -- ( 4,-1.5) -- ( 1,-1);
\path (-4,-1.4) node (a) {}
( 4,-1.4) node (b) {};
\draw[line width=1pt,brown] (-3.5,-3.5) -- (-7.5,-3.5) -- (-3,-3)
( 3.5,-3.5) -- ( 7.5,-3.5) -- ( 3,-3);
\path (-7.5,-3.4) node (c) {}
( 7.5,-3.4) node (d) {}
(-5.5,-3.4) node (e) {}
( 5.5,-3.4) node (f) {};
\end{scope}
% transmission lines
\draw[dashed,gray] (c) -- (aa)
(a) -- (bb)
(e) -- (cc)
(b) -- (dd)
(f) -- (ee)
(d) -- (ff);
\end{tikzpicture}
}
\end{document}
文档代码
\documentclass{scrartcl}
\usepackage[margin=15mm,landscape]{geometry}
\usepackage{animate}
\begin{document}
\begin{center}
\begin{figure}[htp]
\animategraphics[autoplay,loop]{10}{anim}{}{}
\caption{reactor cycle}
\end{figure}
\end{center}
\end{document}
输出
(再次创建图像魔术师)