Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: Teleprompter Code
Posted:
Mar 23, 2013 3:24 AM


Dear Bruce,
I changed the end of your code into
fY[k_, dt_] := Module[{}, Pause[dt]; Y[[Mod[k, Length[Y]] + 1]]];
Manipulate[ Animate[fY[k, dt], {k, 1, \[Infinity], 1}, AnimationRate > 100, ContentSize > {700, 50}], {dt, {0.05, 0.25, 0.5}}]
fY does now return the content with index k after dt seconds. With this we can set AnimationRate to a high value, to run the animation smoothly, and control the speed of the 'string stream' using dt.
Remark: Neither ListAnimate nor Animate do produce smooth animations on my PC (Mathematica 9, Ubuntu 12.04), with the available options. Without the workaround they are not really useful for me.
Best,
Christoph
PS: Here is the complete code:
X = X = StringJoin@ConstantArray[" ", 25] <> "Let's define calculus terms using this sketch in which you're \ hiking over hills and valleys. You may want to pause this clip now \ in order to study the sketch and when you're ready, hit play. \t\t \ If the shape of the land is regarded as a function f(x), the sketch \ says that you start at a point whose xcoordinate is a and that you \ end at a point whose xcoordinate is b. \tWhile hiking, you'll \ always track the altitudesometimes you're above sea level and \ sometimes you're not. (open new layer)\t\t\t At a blue point, you're \ at the hipoint for that part of the hike. (close/open layer)\t\t\ \t At a red point, you're at the lopoint for that part of the hike. \ (show both layers) \t\t\t The yvalue of each blue point is called \ a maximum (WRITE THIS OUT in blue) and the yvalue of each red point \ is called a minimum (WRITE THIS OUT in red). The blue points' \ yvalues are collectively called the maxima (in BLUE) and likewise \ (in RED) minima for the red points. If you're wondering why the green peak isn't \ blue, it's because the hike ends before you reach that peak,\t ";
L = StringLength@X; subLength = 80;
Clear@Y; Y = (y = StringTake[X, {#, Min[# + subLength, L]}]; Style[y, Blue, Bold, 12, FontFamily > "Courier"]) & /@ Range@L; fY[k_, dt_] := Module[{}, Pause[dt]; Y[[Mod[k, Length[Y]] + 1]]]; Manipulate[ Animate[fY[k, dt], {k, 1, \[Infinity], 1}, AnimationRate > 100, ContentSize > {700, 50}], {dt, {0.05, 0.25, 0.5}}]
On 03/22/2013 09:18 AM, bruce.colletti@gmail.com wrote: > The Washington DCArea Mathematica Special Interest Group has been collaborating to build teleprompter code. The code below is the brainchild of Dan Martinez and we've been tinkering with it. We've also looked at ot her code, notably from the Great Guru himself, Harry Calkins. > > Here's my question about the code below: why does ListAnimate inexplicably pause sometimes? The text should run smoothly until the end. > > Tech Support says there's an issue with ListAnimate, one tied to AnimationRate: if it's "good", the passage will scroll smoothly. Otherwise not. I can get it to run smoothly when the rate is highbut then I can't follow the words. > > Can this code be fixed so that the text always runs smoothly for any rate? Thanks. > > Bruce > > X=StringJoin@ConstantArray[" ",25] <>"Let's define calculus terms using this sketch in which you're hiking over hills and valleys. You may want to pause this clip now in order to study the sketch and when you're ready, hit play. \t\t If the shape of the land is regarded as a function f(x), the sketch says that you start at a point whose xcoordinate is a and that you end at a point whose xcoordinate is b. \tWhile hiking, you'll always track the altitudesometimes you're above sea level and sometimes you're not. (open new layer)\t\t\t At a blue point, you're at the hipoint for that part of the hike. (close/open layer)\t\t\t At a red point, you're at the lopoint for that part of the hike. (show both layers) \t\t\t The yvalue of each blue point is called a maximum (WRITE THIS OUT in blue) and the yvalue of each red point is called a minimum (WRITE THIS OUT in red). The blue points' yvalues are collectively called the maxima (in BLUE) and likewise (in RED) minima for > the red points. If you're wondering why the green peak isn't blue, it's because the hike ends before you reach that peak,\t "; > > L=StringLength@X; > subLength=80; > > Clear@Y; > Y=(y=StringTake[X,{#,Min[#+subLength,L]}]; > Style[y,Blue,Bold,12,FontFamily>"Courier"])&/@Range@L; > > ListAnimate[Y,AnimationRate>20,ContentSize>{700,50},AnimationRepetitions>\[Infinity]] >



