Re: automatic animations
- To: mathgroup at smc.vnet.net
- Subject: [mg8376] Re: automatic animations
- From: "Theodore W. Gray" <theodore>
- Date: Tue, 26 Aug 1997 20:41:11 -0400
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
The following function will select all the output from an evaluation, close the group it is in (so only the first graphic is visible), and then start animating it. StartAnimation[t___] := ( SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEndToken[EvaluationNotebook[], "SelectionCloseAllGroups"]}]; SelectionAnimate[EvaluationNotebook[], t]; ) The optional parameter t specifies for how many seconds the animation should be run. If it's not there, then the animation runs forever (until the user clicks somewhere). StartAnimation[] needs to be included in the same cell as the command that produced the graphics output, otherwise it won't work. For example, put these two lines in the same cell and you'll get an animating graphic: Plot[Sin[n x], {x, 0, 2Pi}], {n, 1, 2, 0.2}]; StartAnimation[] You can read about all these sorts of functions in my new book, The Beginner's Guide to Mathematica V3, available at: http://www.mathware.com/BeginnersGuide Theodore W. Gray