Select Git revision
anim.script
Forked from
gmsh / gmsh
18003 commits behind the upstream repository.
anim.script 2.00 KiB
// This script creates an mpeg or gif animation by looping over all
// the time steps and/or all the post-processing views
neww = GetValue("Width of animation? (enter 0 to keep current width)", 640);
newh = GetValue("Height of animation? (enter 0 to keep current height)", 640) ;
all = GetValue("Animate one view at a time or all views together?
0: one at a time, 1: all together", 1) ;
method = GetValue("Animation encoder?
0: mpeg_encode (MPEG1), 1: mencoder (MPEG4), 2: whirlgif (GIF89)", 0) ;
MPEG_ENCODE = 0;
MENCODER = 1;
WHIRLGIF = 2;
oldw = General.GraphicsWidth;
oldh = General.GraphicsHeight;
If(neww)
General.GraphicsWidth = neww;
EndIf
If(newh)
General.GraphicsHeight = newh;
EndIf
If(all)
maxstep = 1;
For i In {1:PostProcessing.NbViews}
View[i-1].TimeStep = 0;
// compute max num of steps
If(View[i-1].Visible)
If(View[i-1].NbTimeStep > maxstep)
maxstep = View[i-1].NbTimeStep;
EndIf
EndIf
EndFor
For index In {1:maxstep}
Draw;
If(method == WHIRLGIF)
Print Sprintf("/tmp/tmp%03g.gif", index);
EndIf
If(method == MPEG_ENCODE || method == MENCODER)
Print Sprintf("/tmp/tmp%03g.jpg", index);
EndIf
For i In {1:PostProcessing.NbViews}
View[i-1].TimeStep++;
EndFor
EndFor
EndIf
If(!all)
// Hide all views
For i In {1:PostProcessing.NbViews}
View[i-1].Visible = 0;
View[i-1].TimeStep = 0;
EndFor
index = 0;
For i In {1:PostProcessing.NbViews}
// Display view i-1
View[i-1].Visible = 1;
// Loop on all solutions in view i-1
For j In {1:View[i-1].NbTimeStep}
index++;
Draw;
If(method == WHIRLGIF)
Print Sprintf("/tmp/tmp%03g.gif", index);
EndIf
If(method == MPEG_ENCODE || method == MENCODER)
Print Sprintf("/tmp/tmp%03g.jpg", index);
EndIf
View[i-1].TimeStep++;
EndFor
View[i-1].Visible = 0;
EndFor
EndIf
NUM_FRAMES = index;
ENCODER = method;
Include "encode.script";
General.GraphicsWidth = oldw;
General.GraphicsHeight = oldh;