Create an animation to pause at the specified location
tlist = Range[0, 2 Pi, 2 Pi/180];
pauseat = {Pi/2, 2 Pi/3, Pi, 7 Pi/6, 3 Pi/2};
pausepos = Nearest[tlist -> Automatic, #] & /@ pauseat;
reps = 10;
tlist2 = Flatten[MapAt[ConstantArray[#, reps] &, tlist, pausepos]];
You can use tlist2
in Animate
iterator:
Animate[f[t], {t, tlist2}, DisplayAllSteps -> True]
or to generate a table of frames to be used in ListAnimate
:
labeling = Thread[tlist[[Flatten @ pausepos]] -> {1/4, 1/3, 1/2, 2/3, 3/4}];
frames = Table[If[MemberQ[tlist[[Flatten @ pausepos]], t],
Replace[f[t], Text[txt : (t /. labeling), p_] :>
Text[Style[txt, 16, Blue, Bold], p], All], f[t]],
{t, tlist2}];
ListAnimate[frames, DisplayAllSteps -> True]
Export frames
as a gif
file:
Export["stutteringclock.gif", frames]
A simpler alternative (but ... sometimes skips a stop):
pauseat = N @ {Pi/2, 2 Pi/3, Pi, 7 Pi/6, 3 Pi/2};
nF = Nearest[pauseat];
Animate[If[PossibleZeroQ[Chop[t - nF[t][[1]], Pi/620]], Pause[1]; f[t], f[t]],
{t, 0, 2 Pi, Pi/620}, DisplayAllSteps -> True, AnimationRate -> 100]
What I’ve done in the past is something like anim = Table[f[t], {t, 0, 2Pi, 0.01}]
and then Export[“anim.gif”, anim, ImageResolution -> 300, “DisplayDurations” -> listOfTimes]
, where listOfTimes
is generated so that most frames have the same display duration, but the frames of interest have a much longer display duration.