In my MWE I have a simple path (circle) and I overlay the path - using a tikz postaction - with the same path but with another line with and another color.
The reference (thanks @MarkWibrow) of the tricky code snippets is in the code. But I do not think that this is relevant for this problem.
The overlay starts at 3 o'clock and goes from there counter-clockwise.
Question(s)
- How can I influence the direction (clockwise or counter-clockwise)
- How can I influence the starting point/origin/beginning of the path (here it's apparently 3 o'clock)?
Code
\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations}
% taken from https://tex.stackexchange.com/questions/247742
% user https://tex.stackexchange.com/users/23215/mark-wibrow
\makeatletter
\tikzset{%
get path length/.code={%
\tikz@addoption{%
\pgfgetpath\tikz@tmppath%
\pgfprocessround\tikz@tmppath\tikz@tmppath%
\pgf@decorate@parsesoftpath\tikz@tmppath\tikz@discard%
\global\let#1=\pgf@decorate@totalpathlength%
}%
}
}
\makeatother
% taken from https://tex.stackexchange.com/questions/347336
% user https://tex.stackexchange.com/users/23215/mark-wibrow
\tikzset{myOwnStyle/.style={
get path length=\pathlength,
draw=black,
line width=1mm,
postaction={
draw=red,
line width=2mm,
dash pattern= on \pathlength/100*#1 off \pathlength/100*(100-#1),
}
}}
\begin{document}
\foreach \n in {0,...,100}{
\begin{tikzpicture}
\draw[myOwnStyle=\n] (0,0) circle [radius = 10mm] node {\n\,\%};
\end{tikzpicture}
}
\end{document}
Output
If somebody is interested, I made the animated GIF by two steps:
- Convert multipage PDF to separate GIF files using this service.
- Converting the separate GIFs to an animated GIF using this or this (was much faster) service.
I just googled for these kind of service - I did not make any further reseach.
Update / Edit
After the very helpful answer of @Torbjørn T. it was clear that a circle was not a wise choice:) - here's a square.
\foreach \n in {0,1,...,100}{
\begin{tikzpicture}[x=1.5mm,y=1.5mm]]
\draw[myOwnStyle=\n] (0,0) -- (10,0) -- (10,10) -- (0,10) -- cycle;
\node at (5,5) {\n\,\%};
\end{tikzpicture}
}



convertutility (provided by ImageMagick):convert -delay 1 -density 150 doc.pdf doc.gif. – Paul Gaborit Jan 08 '17 at 01:46fitandbackgroundslibraries and append this code to the end of tikzpicture:\begin{pgfonlayer}{background} \node[fit=(current bounding box),fill=white]{}; \end{pgfonlayer}. – Paul Gaborit Jan 08 '17 at 01:56-dispose previous, the result is not anti-aliased... – Paul Gaborit Jan 08 '17 at 09:03