I have a problem with Manipulate
. I want to stop my animation depending on a condition on the value A
, which is controlled by a manipulator. I tried to do this by giving the animator specified for variable x
the option AnimationRunning -> If[Tan[A] <= 0.7, False, True]
. That stopped the animation, but didn't stop the animation clock, which depends on the computer's real-clock time. So when the animation is restarted by increasing A
above 0.7, the animation jumps to the place determined by the current clock time, which didn't stop while the graphics updating was paused.
I think I need to stop the animation clock when the graphics updating is paused. My idea is to get access to PlayPauseButton
to click it in code. But i have no idea how to do it..
I will be grateful for any help.
Manipulate[
Graphics[
{
{FaceForm[], EdgeForm[{Thick, Gray}], AASTriangle[Pi/2, A, 1]},
Translate[{{FaceForm[], EdgeForm[{Thickness[0.004], Blue}],
Rotate[{{Rectangle[{0, Sin[A] + 0.006}, {0.15,
Sin[A] + 0.08}]}}, -A, {0, Sin[A]}]}},
{x*Cos[A], -x*Sin[A]}
]
},
PlotRange -> {{0, 1}, {0, 1}}, Axes -> False, ImageSize -> {400, 400}
],
{{A, Pi/4, "A"}, 0.0001, Pi/2 - 0.0001},
{{x, 0}, 0, 1 - 0.15, ControlType -> Animator,
AnimationRunning -> If[Tan[A] <= 0.7, False, True],
AnimationRunTime -> Dynamic[t], AnimationTimeIndex -> Dynamic[indx]},
Dynamic[x],
Dynamic[t],
Dynamic[indx],
ControlPlacement -> Left
]
Manipulate
orAnimate
. I had to fall back on the lower level constructDynamicModule
and implement updating the graphics from the system clock by callingAbsoluteTime
. It wasn't all that hard, but I had to implement my own Play, Pause, and Reset buttons. You might do the same for your code, unless someone smarter than me comes up with a way to do withManipulate
. $\endgroup$