8

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

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

1 Answer 1

14

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
12
  • How the series of pdf images is converted to gif animation?
    – Zarko
    Aug 14, 2019 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, 2019 at 16:11
  • 1
    @DavidPurton A better use: \node at (\angle:1) {\textcolor{blue}{$\bullet$}};
    – Black Mild
    Aug 15, 2019 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. Aug 15, 2019 at 4:27
  • 1
    @BlackMild, that's basically what I put in my most recent update. Thanks for your suggestions! Aug 15, 2019 at 5:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .