#!/bin/sh # Create the template Gnuplot command file cat > sinc.$$.gnuplot << EOF #!/opt/local/bin/gnuplot #!/usr/local/bin/gnuplot #!/usr/bin/gnuplot set isosamples 20,20 set hidden3d set samples 12345 set terminal gif transparent size 640,480 xffffff set output "OUTFILE" set view 45,30 set nokey set noxtics set noytics set noztics set noborder splot [-15:15] [-15:15] [-2:2] sin(sqrt(x*x+y*y)-000)/sqrt(x*x+y*y) #pause -1 "press return" EOF two_pi='8*a(1)' phase=0 phase_index=0 phase_num=15 test=1 while expr $phase_index \< $phase_num > /dev/null do phase=`echo 'scale=40 ;' $two_pi '*' $phase_index.0 '/' $phase_num.0 | bc -l` if expr $phase_index \< 10 > /dev/null ; then phase_index=000${phase_index} elif expr $phase_index \< 100 > /dev/null ; then phase_index=00${phase_index} elif expr $phase_index \< 1000 > /dev/null ; then phase_index=0${phase_index} fi outfile="sinx-$phase_index.gif" echo "phase $phase outfile $outfile" cat sinc.$$.gnuplot \ | sed -e "s/000/$phase/" \ | sed -e "s/OUTFILE/$outfile/" \ > sinc.$$.gp chmod a+x sinc.$$.gp ./sinc.$$.gp phase_index=`expr $phase_index + 1` done rm sinc.$$.gp rm sinc.$$.gnuplot for gif_file in sinx-[0-9][0-9][0-9][0-9].gif ; do small_pnm_file=`echo $gif_file | sed -e 's/\.gif$/-small.pnm/'` small_gif_file=`echo $gif_file | sed -e 's/\.gif$/-small.gif/'` # The reason for rendering a larger image then shrinking resolution # is to antialias lines. In order to do this correctly, the line # width should be 1/scale where scale is the reduction factor. # Unfortunately, gnuplot does not correctly implement linewidths for # the "gif" terminal type. We can therefore not allow 'scale' to be # too large, otherwise the lines become too faint to be visible. giftopnm $gif_file \ | pnmcrop -left \ | pnmcrop -right \ | pnmscale 0.50 \ > $small_pnm_file pnm_info=`pnmfile $small_pnm_file` width=`echo $pnm_info | cut -d, -f2 | cut -db -f1` height=`echo $pnm_info | cut -dy -f2 | cut -dm -f1` pnmcut 0 52 $width 130 $small_pnm_file \ | ppmquant 16 \ | ppmtogif -sort \ > $small_gif_file rm $small_pnm_file done rm sinx-[0-9][0-9][0-9][0-9].gif echo whirlgif -time 4 -loop 0 -o sinx-movie.gif sinx-[0-9][0-9][0-9][0-9]-small.gif