Skip to main content
Tweeted twitter.com/StackMma/status/1089312235770519552
Major clean-up
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

I have a problem with ManipulateManipulate. I want to stop animate x variable dependingmy animation depending on a condition on the value (like if)A, which is controlled by a manipulator. I tried AnimationRunningto do this by giving the animator specified for variable -> If[Tan[A] <= 0x the option AnimationRunning -> If[Tan[A] <= 0.7, False, True].7, False, True] That stopped the animation, but that didn't stop the animation timeclock, which depends on the computer's real-clock time. So when If returns Falsethe animation is stopped, but when If state changes to Truerestarted by increasing A above 0.7, the animation jumps to the place estimateddetermined by the current clock-animation time, which didn't stop while the graphics updating was paused. I

I think iI need to resetstop the animation clock when the graphics updating is paused. My idea is to get access to PlayPauseButtonPlayPauseButton 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
 ]

enter image description here

I have a problem with Manipulate. I want to stop animate x variable depending on condition (like if). I tried AnimationRunning -> If[Tan[A] <= 0.7, False, True], but that didn't stop the animation time, which depends on real-clock time. So when If returns False animation is stopped, but when If state changes to True, animation jumps to the place estimated by clock-animation. I think i need to reset animation clock. 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
 ]

enter image description here

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
 ]

enter image description here

Source Link

Animation time problem

I have a problem with Manipulate. I want to stop animate x variable depending on condition (like if). I tried AnimationRunning -> If[Tan[A] <= 0.7, False, True], but that didn't stop the animation time, which depends on real-clock time. So when If returns False animation is stopped, but when If state changes to True, animation jumps to the place estimated by clock-animation. I think i need to reset animation clock. 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
 ]

enter image description here