![在顶点自动播放动画,但不在边上播放](https://linux22.com/image/372141/%E5%9C%A8%E9%A1%B6%E7%82%B9%E8%87%AA%E5%8A%A8%E6%92%AD%E6%94%BE%E5%8A%A8%E7%94%BB%EF%BC%8C%E4%BD%86%E4%B8%8D%E5%9C%A8%E8%BE%B9%E4%B8%8A%E6%92%AD%E6%94%BE.png)
我想让顶点动画自动播放(如果可能的话会快一点),但不让边缘动画自动播放。请指导我。
\begin{animateinline}{40}
\multiframe{200}{n=0+0.005}{
\begin{tikzpicture}
\draw (7,0)[line width=1pt]--(11,0);
\draw (7,0)[line width=1pt]--(7,4);
\draw (7,4)[line width=1pt]--(11,4);
\draw (11,0)[line width=1pt]--(11,4);
\draw (7,0)[white,line width=1pt]--(8,1);
\draw (7,4)[white,line width=1pt]--(8,3);
\draw (11,0)[white,line width=1pt]--(10,1);
\draw (11,4)[white,line width=1pt]--(10,3);
\draw (8,1)[line width=1pt]--(8,3);
\draw (8,1)[line width=1pt]--(10,1);
\draw (10,1)[line width=1pt]--(10,3);
\draw (8,3)[line width=1pt]--(10,3);
\draw(7,4) [fill=red] circle (3pt);
\draw(11,4) [fill=red] circle (3pt);
\draw(7,0) [fill=red] circle (3pt);
\draw(11,0) [fill=red] circle (3pt) ;
\draw(8,1) [fill=red] circle (3pt);
\draw(8,3) [fill=red] circle (3pt);
\draw(10,1) [fill=red] circle (3pt);
\draw(10,3) [fill=red] circle (3pt);
\pgfmathsetmacro{\k}{(3*\n} % animates as long as \n is negative
\draw(7,4) [fill=blue] circle ({\k*1.35pt});
\draw(11,4) [fill=blue] circle ({\k*1.35pt});
\draw(7,0) [fill=blue] circle ({\k*1.35pt});
\draw(11,0) [fill=blue] circle ({\k*1.35pt}) ;
\draw(8,1) [fill=blue] circle ({\k*1.35pt});
\draw(8,3) [fill=blue] circle ({\k*1.35pt});
\draw(10,1) [fill=blue] circle ({\k*1.35pt});
\draw(10,3) [fill=blue] circle ({\k*1.35pt});
%\pgfmathsetmacro{\m}{\n} % <-animation will only start when \n is positive
\begin{scope}[fill opacity=4]
\filldraw[fill=blue,draw=blue,line width=1pt] (7,0)--(7+\n,0+3*\n);
\filldraw[fill=blue,draw=blue,line width=1pt] (7,0)--(7+3*\n, 0+\n);
\filldraw[fill=blue,draw=blue,line width=1pt] (7,4)--(7+\n, 4-3*\n);
\filldraw[fill=blue,draw=blue,line width=1pt] (7,4)--(7+3*\n, 4-\n);
\filldraw[fill=blue,draw=blue,line width=1pt] (11,4)--(11-3*\n, 4-\n);
\filldraw[fill=blue,draw=blue,line width=1pt] (11,4)--(11-\n, 4-3*\n);
\filldraw[fill=blue,draw=blue,line width=1pt] (11,0)--(11-\n, 0+3*\n);
\filldraw[fill=blue,draw=blue,line width=1pt] (11,0)--(11-3*\n, 0+\n);
\end{scope}
\draw(7,0)node[red,left=2pt]{\Large $v_2'$};
\draw(7,4)node[red,left=2pt]{\Large $v_1'$};
\draw(11,0)node[red,right=2pt]{\Large $v_3'$};
\draw(11,4)node[red,right=2pt]{\Large $v_4'$};
\draw(8,1)node[red,left=2pt]{ $v_2$};
\draw(8,3)node[red,left=2pt]{ $v_1$};
\draw(10,1)node[red,right=2pt]{ $v_3$};
\draw(10,3)node[red,right=2pt]{ $v_4$};
\draw(9,0)node[below=7mm]{$D_2^*(C_4)$};
\end{tikzpicture}}
\end{animateinline}
答案1
您的大部分问题已在↗我的答案回答你之前的问题。关键是使用两个\multiframe
来将动画分成两个部分。后续部分\multiframes
必须始终用 分隔\newframe
,但这里我们使用带星号的变体,\newframe*
,以便在中间插入暂停。单击鼠标后动画将继续。
您可以通过减少此部分的帧数(101
--> )并同时51
增加增量(0.03pt
--> )来加快顶点不断增长的第一个动画部分的速度。0.06pt
(需要 Acrobat Reader 或 Foxit)
\documentclass{article}
\usepackage[a6paper]{geometry}
\usepackage{tikz}
\usepackage{animate}
\newcommand\staticParts{%
\draw (7,0)[line width=1pt]--(11,0);
\draw (7,0)[line width=1pt]--(7,4);
\draw (7,4)[line width=1pt]--(11,4);
\draw (11,0)[line width=1pt]--(11,4);
\draw (7,0)[white,line width=1pt]--(8,1);
\draw (7,4)[white,line width=1pt]--(8,3);
\draw (11,0)[white,line width=1pt]--(10,1);
\draw (11,4)[white,line width=1pt]--(10,3);
\draw (8,1)[line width=1pt]--(8,3);
\draw (8,1)[line width=1pt]--(10,1);
\draw (10,1)[line width=1pt]--(10,3);
\draw (8,3)[line width=1pt]--(10,3);
\draw (7,0)[blue,line width=1pt]--(8,3);
\draw (7,0)[blue,line width=1pt]--(10,1);
\draw (7,4)[blue,line width=1pt]--(8,1);
\draw (7,4)[blue,line width=1pt]--(10,3);
\draw (11,4)[blue,line width=1pt]--(8,3);
\draw (11,4)[blue,line width=1pt]--(10,1);
\draw (11,0)[blue,line width=1pt]--(10,3);
\draw (11,0)[blue,line width=1pt]--(8,1);
\draw(7,0)node[left=2pt]{\Large $v_2'$};
\draw(7,4)node[left=2pt]{\Large $v_1'$};
\draw(11,0)node[right=2pt]{\Large $v_3'$};
\draw(11,4)node[right=2pt]{\Large $v_4'$};
\draw(8,1)node[left=2pt]{ $v_2$};
\draw(8,3)node[left=2pt]{ $v_1$};
\draw(10,1)node[right=2pt]{ $v_3$};
\draw(10,3)node[right=2pt]{ $v_4$};
\draw(9,0)node[below=7mm]{$D_2^*(C_4)$};
}
\newcommand\vertices[1]{%
\draw(7,4) [fill=black] circle (#1);
\draw(11,4) [fill=black] circle (#1);
\draw(7,0) [fill=black] circle (#1);
\draw(11,0) [fill=black] circle (#1);
\draw(8,1) [fill=black] circle (#1);
\draw(8,3) [fill=black] circle (#1);
\draw(10,1) [fill=black] circle (#1);
\draw(10,3) [fill=black] circle (#1);
}
\newcommand\edges[1]{%
\draw[draw=red,line width=1pt] (7,0)--(7+#1,0+#1);
\draw[draw=red,line width=1pt] (7,4)--(7+#1, 4-#1);
\draw[draw=red,line width=1pt] (11,0)--(11-#1, 0+#1);
\draw[draw=red,line width=1pt] (11,4)--(11-#1, 4-#1);
}
\begin{document}
\begin{animateinline}[autoplay]{40}
\multiframe{51}{d=0pt+0.06pt}{ %d=0pt,0.06pt,...,3pt
\begin{tikzpicture}
\staticParts
\vertices{\d}
\end{tikzpicture}
}
\newframe* %insert pause, click to continue
\multiframe{101}{n=0.0+0.01}{ %n=0,0.01,...,1.0
\begin{tikzpicture}
\staticParts
\edges{\n}
\vertices{3pt}
\end{tikzpicture}
}
\end{animateinline}
\end{document}