Drawing a circle with nodes shift with Tikz
I think something like this is what you're after.
\documentclass{beamer}
\usepackage{tikz}
% define a counter
\newcount\CircNum
% macro to hold a color name
\newcommand\Clr{black}
\begin{document}
\begin{frame}
% set up an animation, \CircNum changes from 1 to 17
% with each frame
\animatevalue<1-17>{\CircNum}{1}{17}
\begin{tikzpicture}
% draw the main circle
\node [circle, draw, minimum size=8cm] (c) {};
\foreach \a in {1,2,...,17}{
% if \a is equal to \CircNum, set the color to blue
% otherwise set it to black
\ifnum\a=\the\CircNum
\renewcommand\Clr{blue}
\else
\renewcommand\Clr{black}
\fi
% make a new node for the small circles
\node[\Clr, % with the color defined by the macro
draw, thick, % draw the outline
fill, % fill it
minimum size=5mm, % set the size
circle, % circular shape
label={[\Clr]\a*360/17+180:\a} % add the number on the inside
] at (c.\a*360/17) % position it on the edge of the main circle
{};
}
\end{tikzpicture}
\end{frame}
\end{document}
Here are the first three slides of the PDF:
Welcome to TeX.SE!
Here is a solution that borrows \int_step_variable:nnnNn
from expl3
:
\documentclass{beamer}
\usepackage{expl3}
\usepackage{tikz}
\ExplSyntaxOn
% Borrow a loop macro from expl3
\cs_set_eq:NN \intstepvariable \int_step_variable:nnnNn
\ExplSyntaxOff
\begin{document}
\begin{frame}{Circles in circle}
\begin{center}
\begin{tikzpicture}
\def\nsteps{10}
\def\bigcircleradius{3cm}
\def\smallcirclewidth{0.5cm}
% The big circle
\node[circle, minimum width=2*\bigcircleradius, draw] (C) {};
% The small circles and their labels
\intstepvariable{0}{1}{\nsteps - 1}{\i}{% {init}{step}{final}{variable}
\pgfmathsetmacro{\angle}{90 - \i*360/\nsteps}
\pgfmathsetmacro{\otherside}{\angle+180}
\pgfmathsetmacro{\iplusone}{int(\i+1)}
\pgfmathsetmacro{\iplustwo}{int(\i+2)}
\uncover<\iplustwo-> {
\node[circle, draw, minimum width=2*\smallcirclewidth,
label=\otherside:\iplusone] at (C.\angle) {};
}
\uncover<\iplustwo> { % fill one small circle per frame
\node[circle, fill=red!20, minimum width=2*\smallcirclewidth]
at (C.\angle) {};
}
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
...
...
Note: as an alternative to the following code:
\pgfmathsetmacro{\iplustwo}{int(\i+2)}
(...)
\uncover<\iplustwo-> { (...) }
\uncover<\iplustwo> { (...) }
one could use, assuming e-TeX extensions are available:
\uncover<\the\numexpr \i+2\relax-> { (...) }
\uncover<\the\numexpr \i+2\relax> { (...) }
Now, let's redo the same beamer
presentation, but using a more straightforward order (small circles at angles 1*360/10, 2*360/10, ..., 10*360/10 degrees, respectively). The main code is written in a (slightly) different way from the previous example: it uses two loops and the \pause
macro from beamer
, whereas the first example did everything in one loop, and used only \uncover
.
\documentclass{beamer}
\usepackage{expl3}
\usepackage{tikz}
\ExplSyntaxOn
% Borrow a loop macro from expl3
\cs_set_eq:NN \intstepvariable \int_step_variable:nnnNn
\ExplSyntaxOff
\begin{document}
\begin{frame}{Circles in circle}
\begin{center}
\begin{tikzpicture}
\def\nsteps{10}
\def\bigcircleradius{3cm}
\def\smallcirclewidth{0.5cm}
% The big circle
\node[circle, minimum width=2*\bigcircleradius, draw] (C) {};
% The filled circles: highlight a single small circle on each frame starting
% from frame 2.
\intstepvariable{2}{1}{\nsteps+1}{\i}{% {init}{step}{final}{variable}
\pgfmathsetmacro{\angle}{(\i-1)*360/\nsteps}
\uncover<\i>{
\node[circle, fill=red!20, minimum width=2*\smallcirclewidth]
at (C.\angle) {};
}
}
% The unfilled circles and their labels
\intstepvariable{1}{1}{\nsteps}{\i}{% {init}{step}{final}{variable}
\pgfmathsetmacro{\angle}{\i*360/\nsteps}
\pgfmathsetmacro{\otherside}{\angle+180}
\pause
\node[circle, draw, minimum width=2*\smallcirclewidth, label=\otherside:\i]
at (C.\angle) {};
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
...
...