एनिमेटेड ग्राफ्टिंग
मैं एक एनीमेशन के उपयोग के माध्यम से अपनी थीसिस से परिणाम प्रदर्शित करने की कोशिश कर रहा हूं। मैंने जो भी करने की कोशिश की है उसके लिए मैंने एक MWE का निर्माण किया। अनिवार्य रूप से, मेरे पास वर्टीकल का एक गुच्छा है, जिसका भरा हुआ रंग हर बार के अंक के लिए नमूना आरजीबी मूल्यों द्वारा दिया जाता है जिसे मैंने एक सीएसवी तालिका के भीतर दर्ज किया है। मैं समय के ग्राफ के रंग विकास को एक एनीमेशन के माध्यम से दिखाना चाहूंगा। हालाँकि मैं वास्तव में इसके बारे में जाने के सर्वोत्तम तरीके के बारे में निश्चित नहीं हूँ। इसीलिए मैं इस विषय पर आपकी राय / सुझाव सुनना चाहूंगा। निम्नलिखित कोड तीन कोने के साथ एक ग्राफ उत्पन्न करता है।
\documentclass{standalone}
\usepackage{tikz,calc}
\begin{document}
\begin{tikzpicture}[align=center,node distance=5cm]
\tikzset{
vertex/.style={draw,circle, line width=3pt,minimum size=1cm,text width=1cm, align=center, font=\Large},
arc/.style={draw, line width = 3pt,-}}
% outer shell
\node[vertex] (V1) at (0,0) {1};
\node[vertex] (V2) [below right of = V1] {2};
\node[vertex] (V3) [above of = V2] {3};
% adjacency
\draw[arc] (V1) -- (V2);
\draw[arc] (V3) -- (V2);
\draw[arc] (V3) -- (V1);
\end{tikzpicture}
\end{document}
इसके अलावा, मेरे पास निम्नलिखित प्रविष्टियों के साथ एक तालिका CSV तालिका है:
r1,g1,b1,r2,g2,b2,r3,g3,b3
0.8147,0.1576,0.6557,0.7060,0.4387,0.2760,0.7513,0.8407,0.3517
0.9058,0.9706,0.0357,0.0318,0.3816,0.6797,0.2551,0.2543,0.8308
0.1270,0.9572,0.8491,0.2769,0.7655,0.6551,0.5060,0.8143,0.5853
0.9134,0.4854,0.9340,0.0462,0.7952,0.1626,0.6991,0.2435,0.5497
0.6324,0.8003,0.6787,0.0971,0.1869,0.1190,0.8909,0.9293,0.9172
0.0975,0.1419,0.7577,0.8235,0.4898,0.4984,0.9593,0.3500,0.2858
0.2785,0.4218,0.7431,0.6948,0.4456,0.9597,0.5472,0.1966,0.7572
0.5469,0.9157,0.3922,0.3171,0.6463,0.3404,0.1386,0.2511,0.7537
0.9575,0.7922,0.6555,0.9502,0.7094,0.5853,0.1493,0.6160,0.3804
0.9649,0.9595,0.1712,0.0344,0.7547,0.2238,0.2575,0.4733,0.5678
r1, g1, b1 नोड 1 और इसी तरह के आरजीबी मूल्य हैं।
सारी मदद के लिए धन्यवाद!
संपादित करें: यदि संभव हो तो मैं आरजीबी भरण विकल्प का उपयोग करना चाहूंगा:
\node[...,fill={rgb:red,4;green,2;blue,1}]
जवाब
यह समाधान LaTeX3 फ़ंक्शन के माध्यम से फ़ाइल से रंगों के साथ लाइनों को पढ़ता है। इसके अलावा, यह समय से पहले लूप से \multiframebreakबाहर निकलने के लिए नई कमांड का उपयोग करता है \multiframe। ( animate[ 2020/08/29])
\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage{tikz,calc,animate}
\begin{filecontents}[overwrite,noheader]{vertexcolours.dat}
r1,g1,b1,r2,g2,b2,r3,g3,b3
0.8147,0.1576,0.6557,0.7060,0.4387,0.2760,0.7513,0.8407,0.3517
0.9058,0.9706,0.0357,0.0318,0.3816,0.6797,0.2551,0.2543,0.8308
0.1270,0.9572,0.8491,0.2769,0.7655,0.6551,0.5060,0.8143,0.5853
0.9134,0.4854,0.9340,0.0462,0.7952,0.1626,0.6991,0.2435,0.5497
0.6324,0.8003,0.6787,0.0971,0.1869,0.1190,0.8909,0.9293,0.9172
0.0975,0.1419,0.7577,0.8235,0.4898,0.4984,0.9593,0.3500,0.2858
0.2785,0.4218,0.7431,0.6948,0.4456,0.9597,0.5472,0.1966,0.7572
0.5469,0.9157,0.3922,0.3171,0.6463,0.3404,0.1386,0.2511,0.7537
0.9575,0.7922,0.6555,0.9502,0.7094,0.5853,0.1493,0.6160,0.3804
0.9649,0.9595,0.1712,0.0344,0.7547,0.2238,0.2575,0.4733,0.5678
\end{filecontents}
\usepackage{expl3}
\ExplSyntaxOn
\ior_new:N \l_colours_stream % file descriptor
\seq_new:N \g_colours_seq % sequence var taking colours at a given time
\ior_open:Nn \l_colours_stream {vertexcolours.dat} % open file for reading
\ior_str_get:NN \l_colours_stream \l_tempa_tl % read table header and throw away
\cs_new:Npn\readColours{
\seq_gclear:N \g_colours_seq
\ior_str_get:NNT \l_colours_stream \l_tempa_tl{
\seq_gset_split:NnV \g_colours_seq {,} \l_tempa_tl
}
}
\cs_new:Npn\getColourByIndex#1{
\seq_item:Nn \g_colours_seq {#1}
}
\ExplSyntaxOff
%\makeatletter
%\def\multiframebreak{\global\@anim@mulframecnt=1000}
%\makeatother
\begin{document}
\begin{animateinline}[controls,autoplay,loop]{1}
\readColours%
\multiframe{100}{}{
\begin{tikzpicture}[align=center,node distance=5cm]
\tikzset{
vertex/.style={draw,fill=temp,circle, line width=3pt,minimum size=1cm,text width=1cm, align=center, font=\Large},
arc/.style={draw, line width = 3pt,-}}
% outer shell
\definecolor{temp}{rgb}{\getColourByIndex{1},\getColourByIndex{2},\getColourByIndex{3}}
\node[vertex] (V1) at (0,0) {1};
\definecolor{temp}{rgb}{\getColourByIndex{4},\getColourByIndex{5},\getColourByIndex{6}}
\node[vertex] (V2) [below right of = V1] {2};
\definecolor{temp}{rgb}{\getColourByIndex{7},\getColourByIndex{8},\getColourByIndex{9}}
\node[vertex] (V3) [above of = V2] {3};
% adjacency
\draw[arc] (V1) -- (V2);
\draw[arc] (V3) -- (V2);
\draw[arc] (V3) -- (V1);
\end{tikzpicture}%
\readColours%
\ifthenelse{\equal{\getColourByIndex{1}}{}}{%
\multiframebreak% % no more colours -> break
}{}%
}
\end{animateinline}
\end{document}