[seqfan] Re: animations in Mathematica, OEIS kiosk

William Keith william.keith at gmail.com
Wed Jan 23 19:21:43 CET 2013


On Wed, Jan 23, 2013 at 9:59 AM, Neil Sloane <njasloane at gmail.com> wrote:
> Dear Seq Fans, Two things:
> 1. I need a bit of help with an animation in Mathematica,
> 2. I need more help with the OEIS Kiosk
>
> 1. I want to make an animation that will work in an html file.
> It should produce (successively) these 6 lines:
> 1
> 1 3
> 1 3 5
> 1 3 5 7
> 1 3 5 7 9
> 1 3 5 7 9 11
>
> If I type the following in Mathematica then it works, sort-of:
>
> row1[n_] := Table[ 2i+1, {i, 0, n}]
> Animate[ row1[n], {n,0,5}, DefaultDuration -> 5, AnimationRepetitions -> 1 ]
>
> What I was trying to do was make an animated gif from this by typing
> Export[ "animation.gif", Animate[ row1[n], {n,0,6}, DefaultDuration -> 5,
> AnimationRepetitions -> 1 ] ]
> but that did not work.

When I produce animated gifs with Mathematica, I begin with a table of
graphics elements.  For instance, I used these (in Mathematica 8) to
produce some animations for my class last semester:

picts = Table[
   Show[ParametricPlot[{Sin[5 (t)]*Cos[(t)], Sin[5 (t)]*Sin[(t)]}, {t,
       0, 2*Pi}, PlotStyle -> Thick, PlotRange -> {-1, 1},
     Axes -> False],
    ParametricPlot[{Sin[5 (t + s)]*Cos[(t)],
      Sin[5 (t + s)]*Sin[(t)]}, {t, 0, 2*Pi}, PlotStyle -> Green,
     PlotRange -> {-1, 1}, Axes -> False]], {s, 0, 2 Pi/5, Pi/80}];

Export["SymTest.gif", picts, "GIF", AnimationsRepetition -> Infinity]

picts = Table[
   Show[ParametricPlot[{Sin[5 (t)]*Cos[(t)], Sin[5 (t)]*Sin[(t)]}, {t,
       0, 2*Pi}, PlotStyle -> Thick, PlotRange -> {-1, 1},
     Axes -> False],
    ParametricPlot[{5/Pi (-Pi/5 + s) Sin[5 (t)]*Cos[(t)],
      Sin[5 (t)]*Sin[(t)]}, {t, 0, 2*Pi}, PlotStyle -> Green,
     PlotRange -> {-1, 1}, Axes -> False]], {s, 0, 2 Pi/5, Pi/80}];

Export["Reflection1.gif", picts, "GIF",
 AnimationsRepetition -> Infinity]

-----

So a stab at yours is

EntryData = Table[If[j < i + 1, 2 j - 1, " "], {i, 1, 6}, {j, 1, 6}]

(* You can probably clean that up plenty if you don't like the even
spaces on the end. *)

picts = Table[
  Graphics[Text[TableForm[Table[EntryData[[i]], {i, 1, j}]]]], {j, 1,
   6}];

Export["TriangleOdds.gif", picts, "GIF", AnimationsRepetition -> 1]

When I look at this in Firefox, it loops indefinitely, but that may
just be a quirk of Firefox or my settings.

William Keith



More information about the SeqFan mailing list