7

I have used this tikz to generate some GIF. Here are the code and the result. Any idea to make it better

\documentclass[tikz,border={2pt 2pt 2pt 2pt}]{standalone}
 \usepackage{tikz}
 \begin{document}
 \foreach \angle in {0,10,...,360}
{
 \begin{tikzpicture}
 \draw (0,0) circle (1);
 \node at ({cos(\angle)},{sin(\angle)}) {\textcolor{blue}{$\bullet$}};
 \end{tikzpicture}
   }
\end{document}

enter image description here

  • 3
    add \useasboundingbox (-1.5,-1.5)rectangle(1.5,1.5); – AndréC Aug 14 '19 at 15:02
  • @AndréC Looks like an answer to me – Joseph Wright Aug 14 '19 at 15:11
  • @JosephWright I don't understand, what are you talking about? – AndréC Aug 14 '19 at 15:18
  • @AndréC Joseph's comment means that your comment looks suitable to become a proper answer to this question. :) – Paulo Cereda Aug 14 '19 at 15:23
  • 1
    See tex.stackexchange.com/q/492532/194579. – user194579 Aug 14 '19 at 23:59
12

Update: You could put a larger bounding box around the whole diagram (I think @AndréC's option from the comments is conceptually better than the path I originally had even if the effect is the same), make the loop only go to 350° so you don't get the pause at the end, and change from a bullet in a node to directly drawing a circle. @BlackMild's suggestion to use (\angle:1) instead of the trig functions is also good.

\documentclass[tikz]{standalone}
\begin{document}
\foreach \angle in {0,10,...,350}
{
  \begin{tikzpicture}
    \draw (0,0) circle (1);
    \fill[blue] (\angle:1) circle (0.07);
    \useasboundingbox (-1.1,-1.1) rectangle (1.1,1.1);
  \end{tikzpicture}%
}
\end{document}

MWE output

The animated GIF was created using ImageMagick. It's animation documentation can be found here.

I use a simple shell script for the conversation:

#!/bin/bash

BASE=`basename $1 .pdf`
PDF="$BASE.pdf"
GIF="$BASE.gif"
RESOLUTION=300

CONVERT=/usr/bin/convert
CONVERTOPTS="-density $RESOLUTION -delay 8 -loop 0 -background white -alpha remove"

echo "Converting to TSX GIF..."
$CONVERT $CONVERTOPTS $PDF $GIF > /dev/null
  • How the series of pdf images is converted to gif animation? – Zarko Aug 14 '19 at 15:48
  • @zarko convert -density 300 -delay 4 -loop 0 -alpha remove multipage.pdf animated.gif for 100/4=25 FPS – AlexG Aug 14 '19 at 16:11
  • 1
    @DavidPurton A better use: \node at (\angle:1) {\textcolor{blue}{$\bullet$}}; – Black Mild Aug 15 '19 at 4:20
  • 1
    @BlackMild, Perhaps it would be better to get rid of the node and text all together and just draw a blue circle. I mainly took the question as how can I improve the animation. – David Purton Aug 15 '19 at 4:27
  • 1
    @BlackMild, that's basically what I put in my most recent update. Thanks for your suggestions! – David Purton Aug 15 '19 at 5:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.