(*   This is the file MakeFramesZ2.m, written by

     Douglas N. Arnold  <dna@math.psu.edu>
     Department of Mathematics
     Penn State
     University Park, PA  16802
     
     January 1997, June 1997
*)
      
Needs["homotopyframes`"]
Needs["Graphics`Colors`"]

(* This file makes an animation of a linear homotopy by showing the
   evolution of the image of a rainbow shaded disc.  The frames
   of the evolution are output as GIF files. *)

         (* STEP 1: DESCRIBE THE DESIRED ANIMATION *)

f0[z_]:=z              (* initial and final functions *)
f1[z_]:=z^2            (*   of the homotopy *)

center=0;              (* center, radius, initial angle, and final *)
radius=2;              (* angle of the disc sector to plot *)
arg0=-Pi/2;
arg1=3Pi/2;

llplot=-4.5-4.5 I;     (* lower left and upper right corners of *)
urplot=-llplot;        (* plotting region *)

nframes=11;            (* number of frames in the animation *)

spokes=2200;           (* number of vertical lines (these have varying hue) *)

starthue=0;            (* starting and ending hues for the vertical lines *)
endhue=1;              (*   (both should be in [0,1] ) *)

sthickness=.01;        (* thickness of the colored spokes *)

circles=6;             (* number of r=const. circles to superimpose *)

ccolor=GrayLevel[.25]; (* color of the superimposed circles *)

cthickness=.006        (* thickness of the superimposed circles *)

bdrycolor=White;       (* color of the boundary *)

bdrythickness=.012     (* thickness of the boundary lines *)

pixels=400;            (* size of the image in pixels *)
 
prefix="z2";          (* filename prefix *)

options =              (* general plot options *)
   {Background->Black, DefaultColor->White, AspectRatio->Automatic};


                     (* STEP 2: MAKE THE ANIMATION *)

homotopyframes[
  (* initial function *)
    f0,
  (* final function *)
    f1,
  (* curvelist *)
    Join[
      (* colored radii *)
      (* there is some fiddling with the radius for the spokes, because
         the thickness causes them to be a bit too long *)
      Table[
        spoke@@Join[{center,0,radius-.025,arg0+(arg1-arg0)j/spokes,
          PlotStyle->{{Thickness[sthickness],
                Hue[starthue + (endhue-starthue)j/spokes]}}},
          options],
        {j,0,spokes}],
      (* horizontal grid lines *)
      circlearray@@Join[{center,radius/circles,radius-radius/circles,
        arg0,arg1,circles-1,
        PlotStyle->{{Thickness[cthickness],ccolor}}},
          options],
      (* boundary (it comes out best if we expand it slightly) *)
      {circle@@Join[{center,radius,arg0,arg1,
        PlotStyle->{{Thickness[bdrythickness],bdrycolor}}},
          options]}
      ],
  (* number of frames *)
    nframes,
  (* pixels *)
    pixels,
  (* filename prefix *)
    prefix,
  (* options for each frame *)
    PlotRange->{{Re[llplot],Re[urplot]},{Im[llplot],Im[urplot]}}
];

Print[StringJoin["-- frames written --"]]


