I know that there are other solutions for creating diagrams in LaTeX, especially in TikZ, but I've got the following problem. Consider this MWE with the output:
\documentclass[border=5pt,tikz]{standalone}
\newcommand{\dia}[2]{
\pgfmathsetmacro{\a}{(#1/100)*360}
\pgfmathsetmacro{\b}{(#2/100)*360}
\pgfmathsetmacro{\cc}{100-(#1+#2)}
\pgfmathsetmacro{\c}{(\cc/100)*360}
\fill[blue] (1,0) arc(0:\a+\a:1) -- (0,0) -- cycle;
\fill[green] (1,0) arc(0:\b+\c:1) -- (0,0) -- cycle;
\fill[red] (1,0) arc(0:\c:1) -- (0,0) -- cycle;
\draw[gray,ultra thick] (0,0) -- (\a+\a:1.01);
\draw[gray,ultra thick] (0,0) -- (\b+\c:1.01);
\draw[gray,ultra thick] (0,0) -- (\c:1.01);
\fill[gray] (0,0) circle(.95);
}
\pagecolor{gray}
\begin{document}
\foreach \n in {0,5,...,45,40,35,...,0}
{
\begin{tikzpicture}
\useasboundingbox (-1,-1) rectangle (1,1);
%% \fill[blue] (1,0) arc(0:120:1) --+ (0,-{sin(120)}) -- cycle;
% \fill[blue] (1,0) arc(0:120:1) -- (0,0) -- cycle;
%% \fill[green] (1,0) arc(0:75:1) --+ (0,-{sin(75)}) -- cycle;
% \fill[green] (1,0) arc(0:75:1) -- (0,0) -- cycle;
\dia{50}{\n}
\end{tikzpicture}
}
\end{document}
My question is:
How can I create a command, such that I just have to put \dia{4}{20}{10}{50}, to let TikZ know, that there are four numbers to deal with; the first one represents 20%, the second one 10% and so on and the last one is 100 - [the sum of all previous ones]%?


dash patterns. (Need to run now.) – Sep 26 '18 at 17:44