It's basically replacing Manipulate
with Table
and then Export
.
The only real trick is to make "DisplayDurations"
smaller. "DisplayDurations"
specifies how long each frame should be displayed; the default, I think, is not to specify anything, so then you just fall back to the default of the web browser you're viewing the GIF in, which is typically something like 1/10 second. This indeed makes for very choppy animations.
When possible I try to use "DisplayDurations" -> 1/50
, so the animation is at 50 fps (which, due to the vagaries of the GIF format, is the maximum possible), but this obviously requires more frames and hence a larger filesize. To reduce the size I'll sometimes drop down to "DisplayDurations" -> 3/100
(again, due to the GIF format, the durations have to be multiples of 1/100), or about 33 fps, but this is about as low as I'm willing to go.
I didn't in this case, but sometimes I also need to postprocess the GIF in gifsicle or Gifski to try to reduce filesize in more sophisticated ways.
Anyway, here's the code I used to export the GIF:
squircle =
Block[{invts = {g2[2., 2. I], g3[2., 2. I]}, s, width = .012, n = 8,
c, cols = RGBColor /@ {"#21243d", "#88e1f2"}},
s = WeierstrassP[1, invts];
ParallelTable[
c = 2 Cos[t] # + Sin[t] Cayley[-WeierstrassP[#, invts]/s] &[(1 + I)/2];
Graphics[
{FaceForm[cols[[-1]]],
Table[
Polygon[
Join @@ Transpose[
Table[
ReIm[-c + 2 Cos[t] # +
Sin[t] Cayley[-WeierstrassP[#, invts]/s]] & /@
{x + I (y - width), 1 - x + I (y + width)}, {x, -width, 1 + width, (1 + 2 width)/100}]]],
{y, 0., 1, 1/n}],
Table[
Polygon[
Join @@ Transpose[
Table[
ReIm[-c + 2 Cos[t] # +
Sin[t] Cayley[-WeierstrassP[#, invts]/s]] & /@
{x - width + I y, x + width + I (1 - y)},{y, -width, 1 + width, (1 + 2 width)/100}]]],
{x, 0., 1, 1/n}]},
ImageSize -> 540, PlotRange -> Sqrt[3], Background -> cols[[1]]],
{t, 0., ? - #, #}] &[?/150]
];
Export[NotebookDirectory[] <> "squircle.gif", squircle,
"AnimationRepetitions" -> Infinity, "DisplayDurations" -> 1/50]