Manipulate -> Pause Play at specific conditions
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
How can I pause play in Manipulate when a condition is met ?
Here is an example:
Manipulate[
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10], i, 1, 10,
AnimationRate -> 3, RefreshRate -> 60, Appearance -> "Open"]
When I press the "Play" Buttom, i
increases.
Now, I want the animation to stop automatically, when i
reaches a certain value, say i=5
.
How can I do that ?
EDIT: Thanks a lot for the great answers.
Would it be possible to implement the following:
One can define points for which play will stop, for instance, at i=2, i=4, and i=8
When i== One of the points -> Then play will stop, if I press the play buttom again, then it will continue to run until the next break point:
Example:
i==2 -> Stop
Manually: Press Play
--> Continues
i==4 -> Stop
Manually: Press Play
--> Continues
etc.
list-manipulation manipulate
add a comment |Â
up vote
6
down vote
favorite
How can I pause play in Manipulate when a condition is met ?
Here is an example:
Manipulate[
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10], i, 1, 10,
AnimationRate -> 3, RefreshRate -> 60, Appearance -> "Open"]
When I press the "Play" Buttom, i
increases.
Now, I want the animation to stop automatically, when i
reaches a certain value, say i=5
.
How can I do that ?
EDIT: Thanks a lot for the great answers.
Would it be possible to implement the following:
One can define points for which play will stop, for instance, at i=2, i=4, and i=8
When i== One of the points -> Then play will stop, if I press the play buttom again, then it will continue to run until the next break point:
Example:
i==2 -> Stop
Manually: Press Play
--> Continues
i==4 -> Stop
Manually: Press Play
--> Continues
etc.
list-manipulation manipulate
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
How can I pause play in Manipulate when a condition is met ?
Here is an example:
Manipulate[
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10], i, 1, 10,
AnimationRate -> 3, RefreshRate -> 60, Appearance -> "Open"]
When I press the "Play" Buttom, i
increases.
Now, I want the animation to stop automatically, when i
reaches a certain value, say i=5
.
How can I do that ?
EDIT: Thanks a lot for the great answers.
Would it be possible to implement the following:
One can define points for which play will stop, for instance, at i=2, i=4, and i=8
When i== One of the points -> Then play will stop, if I press the play buttom again, then it will continue to run until the next break point:
Example:
i==2 -> Stop
Manually: Press Play
--> Continues
i==4 -> Stop
Manually: Press Play
--> Continues
etc.
list-manipulation manipulate
How can I pause play in Manipulate when a condition is met ?
Here is an example:
Manipulate[
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10], i, 1, 10,
AnimationRate -> 3, RefreshRate -> 60, Appearance -> "Open"]
When I press the "Play" Buttom, i
increases.
Now, I want the animation to stop automatically, when i
reaches a certain value, say i=5
.
How can I do that ?
EDIT: Thanks a lot for the great answers.
Would it be possible to implement the following:
One can define points for which play will stop, for instance, at i=2, i=4, and i=8
When i== One of the points -> Then play will stop, if I press the play buttom again, then it will continue to run until the next break point:
Example:
i==2 -> Stop
Manually: Press Play
--> Continues
i==4 -> Stop
Manually: Press Play
--> Continues
etc.
list-manipulation manipulate
edited Aug 9 at 6:11
asked Aug 8 at 13:36
james
563316
563316
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Manipulate
by default uses Manipulator
which doesn't seem to support dynamic values for the AnimationRunning
option. However you could use ControlType -> Animator
.
Here's a possible approach where by adding two extra control variables I can stop the animation after i
reaches 5 on the first run.
Manipulate[
If[initialRun && i >= 5, running = False; initialRun = False];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
initialRun, True, False, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3,
RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
Note that if the user interacts with the animator before it gets paused by the Manipulate, the pausing will still happen whenever the value of i
is 5 or greater first.
For a version with more than one breakpoint, replace the initialRun
boolean with an integer counting how many runs have happened:
With[breakPoints = 2, 4, 8,
Manipulate[
If[runNumber <= Length[breakPoints] && i >= breakPoints[[runNumber]],
running = False; runNumber++
];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
runNumber, 1, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3, RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
]
+1 Good idea, it seems I am not able to think in this heat. :)
â Kubaâ¦
Aug 8 at 15:42
+1, I arrived too late.
â rhermans
Aug 8 at 15:44
Thank you very much! Great idea, but I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please see the recent edit for more information
â james
Aug 9 at 6:12
Wow ! This is perfect ! Very well done !! Thank you very much. :))
â james
Aug 9 at 8:35
add a comment |Â
up vote
2
down vote
The credit goes to @Gerli, who arrived first. Difference is that mine uses DynamicModule
DynamicModule[
s = True,
Manipulate[
If[i > 5, s = False, s = True];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10],
i, 1, 10
, ControlType -> Animator
, AnimationRunning -> Dynamic[s]
]
]
Thank you very much! I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please have a look at the recent edit. Thanks :)
â james
Aug 9 at 6:12
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Manipulate
by default uses Manipulator
which doesn't seem to support dynamic values for the AnimationRunning
option. However you could use ControlType -> Animator
.
Here's a possible approach where by adding two extra control variables I can stop the animation after i
reaches 5 on the first run.
Manipulate[
If[initialRun && i >= 5, running = False; initialRun = False];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
initialRun, True, False, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3,
RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
Note that if the user interacts with the animator before it gets paused by the Manipulate, the pausing will still happen whenever the value of i
is 5 or greater first.
For a version with more than one breakpoint, replace the initialRun
boolean with an integer counting how many runs have happened:
With[breakPoints = 2, 4, 8,
Manipulate[
If[runNumber <= Length[breakPoints] && i >= breakPoints[[runNumber]],
running = False; runNumber++
];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
runNumber, 1, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3, RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
]
+1 Good idea, it seems I am not able to think in this heat. :)
â Kubaâ¦
Aug 8 at 15:42
+1, I arrived too late.
â rhermans
Aug 8 at 15:44
Thank you very much! Great idea, but I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please see the recent edit for more information
â james
Aug 9 at 6:12
Wow ! This is perfect ! Very well done !! Thank you very much. :))
â james
Aug 9 at 8:35
add a comment |Â
up vote
4
down vote
accepted
Manipulate
by default uses Manipulator
which doesn't seem to support dynamic values for the AnimationRunning
option. However you could use ControlType -> Animator
.
Here's a possible approach where by adding two extra control variables I can stop the animation after i
reaches 5 on the first run.
Manipulate[
If[initialRun && i >= 5, running = False; initialRun = False];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
initialRun, True, False, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3,
RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
Note that if the user interacts with the animator before it gets paused by the Manipulate, the pausing will still happen whenever the value of i
is 5 or greater first.
For a version with more than one breakpoint, replace the initialRun
boolean with an integer counting how many runs have happened:
With[breakPoints = 2, 4, 8,
Manipulate[
If[runNumber <= Length[breakPoints] && i >= breakPoints[[runNumber]],
running = False; runNumber++
];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
runNumber, 1, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3, RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
]
+1 Good idea, it seems I am not able to think in this heat. :)
â Kubaâ¦
Aug 8 at 15:42
+1, I arrived too late.
â rhermans
Aug 8 at 15:44
Thank you very much! Great idea, but I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please see the recent edit for more information
â james
Aug 9 at 6:12
Wow ! This is perfect ! Very well done !! Thank you very much. :))
â james
Aug 9 at 8:35
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Manipulate
by default uses Manipulator
which doesn't seem to support dynamic values for the AnimationRunning
option. However you could use ControlType -> Animator
.
Here's a possible approach where by adding two extra control variables I can stop the animation after i
reaches 5 on the first run.
Manipulate[
If[initialRun && i >= 5, running = False; initialRun = False];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
initialRun, True, False, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3,
RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
Note that if the user interacts with the animator before it gets paused by the Manipulate, the pausing will still happen whenever the value of i
is 5 or greater first.
For a version with more than one breakpoint, replace the initialRun
boolean with an integer counting how many runs have happened:
With[breakPoints = 2, 4, 8,
Manipulate[
If[runNumber <= Length[breakPoints] && i >= breakPoints[[runNumber]],
running = False; runNumber++
];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
runNumber, 1, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3, RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
]
Manipulate
by default uses Manipulator
which doesn't seem to support dynamic values for the AnimationRunning
option. However you could use ControlType -> Animator
.
Here's a possible approach where by adding two extra control variables I can stop the animation after i
reaches 5 on the first run.
Manipulate[
If[initialRun && i >= 5, running = False; initialRun = False];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
initialRun, True, False, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3,
RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
Note that if the user interacts with the animator before it gets paused by the Manipulate, the pausing will still happen whenever the value of i
is 5 or greater first.
For a version with more than one breakpoint, replace the initialRun
boolean with an integer counting how many runs have happened:
With[breakPoints = 2, 4, 8,
Manipulate[
If[runNumber <= Length[breakPoints] && i >= breakPoints[[runNumber]],
running = False; runNumber++
];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10]
,
runNumber, 1, ControlType -> None,
running, True, False, ControlType -> None,
i, 1, 10, ControlType -> Animator, AnimationRate -> 3, RefreshRate -> 60, AnimationRunning -> Dynamic[running]
]
]
edited Aug 9 at 8:21
answered Aug 8 at 15:32
Gerli
886512
886512
+1 Good idea, it seems I am not able to think in this heat. :)
â Kubaâ¦
Aug 8 at 15:42
+1, I arrived too late.
â rhermans
Aug 8 at 15:44
Thank you very much! Great idea, but I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please see the recent edit for more information
â james
Aug 9 at 6:12
Wow ! This is perfect ! Very well done !! Thank you very much. :))
â james
Aug 9 at 8:35
add a comment |Â
+1 Good idea, it seems I am not able to think in this heat. :)
â Kubaâ¦
Aug 8 at 15:42
+1, I arrived too late.
â rhermans
Aug 8 at 15:44
Thank you very much! Great idea, but I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please see the recent edit for more information
â james
Aug 9 at 6:12
Wow ! This is perfect ! Very well done !! Thank you very much. :))
â james
Aug 9 at 8:35
+1 Good idea, it seems I am not able to think in this heat. :)
â Kubaâ¦
Aug 8 at 15:42
+1 Good idea, it seems I am not able to think in this heat. :)
â Kubaâ¦
Aug 8 at 15:42
+1, I arrived too late.
â rhermans
Aug 8 at 15:44
+1, I arrived too late.
â rhermans
Aug 8 at 15:44
Thank you very much! Great idea, but I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Thank you very much! Great idea, but I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please see the recent edit for more information
â james
Aug 9 at 6:12
Please see the recent edit for more information
â james
Aug 9 at 6:12
Wow ! This is perfect ! Very well done !! Thank you very much. :))
â james
Aug 9 at 8:35
Wow ! This is perfect ! Very well done !! Thank you very much. :))
â james
Aug 9 at 8:35
add a comment |Â
up vote
2
down vote
The credit goes to @Gerli, who arrived first. Difference is that mine uses DynamicModule
DynamicModule[
s = True,
Manipulate[
If[i > 5, s = False, s = True];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10],
i, 1, 10
, ControlType -> Animator
, AnimationRunning -> Dynamic[s]
]
]
Thank you very much! I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please have a look at the recent edit. Thanks :)
â james
Aug 9 at 6:12
add a comment |Â
up vote
2
down vote
The credit goes to @Gerli, who arrived first. Difference is that mine uses DynamicModule
DynamicModule[
s = True,
Manipulate[
If[i > 5, s = False, s = True];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10],
i, 1, 10
, ControlType -> Animator
, AnimationRunning -> Dynamic[s]
]
]
Thank you very much! I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please have a look at the recent edit. Thanks :)
â james
Aug 9 at 6:12
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The credit goes to @Gerli, who arrived first. Difference is that mine uses DynamicModule
DynamicModule[
s = True,
Manipulate[
If[i > 5, s = False, s = True];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10],
i, 1, 10
, ControlType -> Animator
, AnimationRunning -> Dynamic[s]
]
]
The credit goes to @Gerli, who arrived first. Difference is that mine uses DynamicModule
DynamicModule[
s = True,
Manipulate[
If[i > 5, s = False, s = True];
Plot[i*Sin[x], x, 0, 10, PlotRange -> 10],
i, 1, 10
, ControlType -> Animator
, AnimationRunning -> Dynamic[s]
]
]
edited Aug 8 at 15:47
answered Aug 8 at 15:42
rhermans
21.5k439101
21.5k439101
Thank you very much! I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please have a look at the recent edit. Thanks :)
â james
Aug 9 at 6:12
add a comment |Â
Thank you very much! I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please have a look at the recent edit. Thanks :)
â james
Aug 9 at 6:12
Thank you very much! I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Thank you very much! I would need it to stop when i=5 and then when I push the play button it should continue. Is this possible ?
â james
Aug 9 at 5:39
Please have a look at the recent edit. Thanks :)
â james
Aug 9 at 6:12
Please have a look at the recent edit. Thanks :)
â james
Aug 9 at 6:12
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f179690%2fmanipulate-pause-play-at-specific-conditions%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password