x(u,v) = cos(u)*(R + a(u)*cos(v))
y(u,v) = sin(u)*(R + a(u)*cos(v))
z(u,v) = a(u)*sin(v)
#
set pm3d depth lighting primary 0.5  
set palette defined (0 "#6666ff", 1 "#6666ff")
set samples 128
set isosamples 64
unset border
unset tics
unset colorbox
unset key
set xyplane 0
set view 60, 15, 1.8
set parametric
set urange [0:2*pi]
set vrange [-pi:pi]
R = 1
c = 1.3
set xrange [-c:c]
set yrange [-c:c]
set zrange [-c:c]

set term pngcairo size 360,360 backgr "dark-olivegreen"
N = 30
do for [i = 0:N-1] {
  q = 2*pi/N*i
  set out sprintf("img%3d.png",i)
  a(x) = 0.05*(3+sin(q))*(1+0.4*cos(8*x+q))
  splot x(u,v), y(u,v), z(u,v) w pm3d
}
system("convert -adjoin -delay 10 img*.png torus001.gif")
system("rm img*.png")