diff --git a/demos/anim-all.script b/demos/anim-all.script new file mode 100644 index 0000000000000000000000000000000000000000..09232c365ce1f8eeeb4757bdec0fe85dbc364947 --- /dev/null +++ b/demos/anim-all.script @@ -0,0 +1,82 @@ +// +// Animate all visible views and save the animation as a 320x240 mpeg +// and a 320x240 animated gif +// +// Requirements: mpeg_encode, whirlgif and a UNIX shell +// +// Usage: gmsh file(s) anim-all.script +// +// Output: anim.mpg and anim.gif +// + +General.GraphicsWidth = 320 ; +General.GraphicsHeight = 240 ; +PostProcessing.Link = 1; + +For i In {1:View[0].NbTimeStep} + + Draw; + If (i < 10) + Print Sprintf("anim-00%g.jpg", i); + Print Sprintf("anim-00%g.gif", i); + EndIf + If (i >= 10 && i < 100) + Print Sprintf("anim-0%g.jpg", i); + Print Sprintf("anim-0%g.gif", i); + EndIf + If (i >= 100) + Print Sprintf("anim-%g.jpg", i); + Print Sprintf("anim-%g.gif", i); + EndIf + View[0].TimeStep++; + +EndFor + +// create the parameter file for mpeg_encode + +System 'echo "PATTERN I" > anim.par' ; +System 'echo "BASE_FILE_FORMAT JPEG" >> anim.par' ; +System 'echo "GOP_SIZE 30" >> anim.par' ; +System 'echo "SLICES_PER_FRAME 1" >> anim.par' ; +System 'echo "PIXEL HALF" >> anim.par' ; +System 'echo "RANGE 10" >> anim.par' ; +System 'echo "PSEARCH_ALG TWOLEVEL" >> anim.par' ; +System 'echo "BSEARCH_ALG CROSS2" >> anim.par' ; +System 'echo "IQSCALE 8" >> anim.par' ; +System 'echo "PQSCALE 10" >> anim.par' ; +System 'echo "BQSCALE 25" >> anim.par' ; +System 'echo "REFERENCE_FRAME ORIGINAL" >> anim.par' ; +System 'echo "OUTPUT anim.mpg" >> anim.par' ; +System 'echo "INPUT_CONVERT *" >> anim.par' ; +System 'echo "INPUT_DIR ." >> anim.par' ; +System 'echo "INPUT" >> anim.par' ; +If (View[0].NbTimeStep < 10) + System Sprintf('echo "anim-*.jpg [001-00%g]" >> anim.par', View[0].NbTimeStep) ; +EndIf +If (View[0].NbTimeStep >= 10 && View[0].NbTimeStep < 100) + System Sprintf('echo "anim-*.jpg [001-0%g]" >> anim.par', View[0].NbTimeStep) ; +EndIf +If (View[0].NbTimeStep >= 100) + System Sprintf('echo "anim-*.jpg [001-%g]" >> anim.par', View[0].NbTimeStep) ; +EndIf +System 'echo "END_INPUT" >> anim.par' ; + +// Call mpeg_encode + +System "mpeg_encode anim.par" ; + +// Call whirlgif + +System "whirlgif -loop -o anim.gif anim-*.gif" ; + +// Clean-up all temp files + +System "rm -f anim-*.gif" ; +System "rm -f anim-*.jpg" ; +System "rm -f anim.par" ; + +// One could also rename the output files with the view name + +// System StrCat( StrCat("mv anim.gif ", Sprintf(View[0].Name)), ".gif"); +// System StrCat( StrCat("mv anim.mpg ", Sprintf(View[0].Name)), ".mpg"); + diff --git a/demos/anim-seq.script b/demos/anim-seq.script new file mode 100644 index 0000000000000000000000000000000000000000..56407b959120b4daa9d71c4eda3678335d57c023 --- /dev/null +++ b/demos/anim-seq.script @@ -0,0 +1,100 @@ +// +// Animate all loaded views sequentially and save the animation as +// a 320x240 mpeg and a 320x240 animated gif +// +// Requirements: mpeg_encode, whirlgif and a UNIX shell +// +// Usage: gmsh file(s) anim-seq.script +// +// Output: anim.mpg and anim.gif +// + +General.GraphicsWidth = 320 ; +General.GraphicsHeight = 240 ; +PostProcessing.Link = 0; + +// Hide all views + +For i In {1:PostProcessing.NbViews} + View[i-1].Visible = 0; +EndFor + +// Loop on all views + +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 (index < 10) + Print Sprintf("anim-00%g.jpg", index); + Print Sprintf("anim-00%g.gif", index); + EndIf + If (index >= 10 && index < 100) + Print Sprintf("anim-0%g.jpg", index); + Print Sprintf("anim-0%g.gif", index); + EndIf + If (index >= 100) + Print Sprintf("anim-%g.jpg", index); + Print Sprintf("anim-%g.gif", index); + EndIf + View[i-1].TimeStep++; + + EndFor + + View[i-1].Visible = 0; + +EndFor + +// create the parameter file for mpeg_encode + +System 'echo "PATTERN I" > anim.par' ; +System 'echo "BASE_FILE_FORMAT JPEG" >> anim.par' ; +System 'echo "GOP_SIZE 30" >> anim.par' ; +System 'echo "SLICES_PER_FRAME 1" >> anim.par' ; +System 'echo "PIXEL HALF" >> anim.par' ; +System 'echo "RANGE 10" >> anim.par' ; +System 'echo "PSEARCH_ALG TWOLEVEL" >> anim.par' ; +System 'echo "BSEARCH_ALG CROSS2" >> anim.par' ; +System 'echo "IQSCALE 8" >> anim.par' ; +System 'echo "PQSCALE 10" >> anim.par' ; +System 'echo "BQSCALE 25" >> anim.par' ; +System 'echo "REFERENCE_FRAME ORIGINAL" >> anim.par' ; +System 'echo "OUTPUT anim.mpg" >> anim.par' ; +System 'echo "INPUT_CONVERT *" >> anim.par' ; +System 'echo "INPUT_DIR ." >> anim.par' ; +System 'echo "INPUT" >> anim.par' ; +If (index < 10) + System Sprintf('echo "anim-*.jpg [001-00%g]" >> anim.par', index) ; +EndIf +If (index >= 10 && index < 100) + System Sprintf('echo "anim-*.jpg [001-0%g]" >> anim.par', index) ; +EndIf +If (index >= 100) + System Sprintf('echo "anim-*.jpg [001-%g]" >> anim.par', index) ; +EndIf +System 'echo "END_INPUT" >> anim.par' ; + +// Call mpeg_encode + +System "mpeg_encode anim.par" ; + +// Call whirlgif + +System "whirlgif -loop -o anim.gif anim-*.gif" ; + +// Clean-up all temp files + +System "rm -f anim-*.gif" ; +System "rm -f anim-*.jpg" ; +System "rm -f anim.par" ; +