
BeginPackage["UVW`StoGho`"]
(* Version 2.0, 08/15/97 *)

StoGho::usage="
StoGho[width,mood] portraits the gha(us)stly ghost known by the name of StoGho 
in some old castles of Europe. His shape depends on width and mood, modulo 2."

GalleryOfPortraits::usage="
GalleryOfPortraits[matrix] draws an array of portraits of your favorite 
star."


Begin["`Private`"]


StoGho[width_,mood_,opts___]:=

    Block[{h, m, body, eyes, mouth, pupils},
    
         h=Mod[N[width],2.]+2.;
         m=Mod[N[mood],2.]-1.;

     body = Plot[Exp[(-t^2)/(h+1)],{t,-10,10},
                DisplayFunction->Identity,PlotStyle->Thickness[0.009]];


     eyes = ParametricPlot[{{(1/3)*Sin[t]-0.6,((h+m)/60)*Cos[t]+0.5},
                {(1/3)*Sin[t]+0.6,((h+m)/60)*Cos[t]+0.5}},{t,-Pi,Pi},
                DisplayFunction->Identity,PlotStyle->Thickness[0.005]];


     mouth = Plot[(1/10*h)*(t^2)*m+0.2,{t,-0.75,0.75},
                DisplayFunction->Identity,PlotStyle->Thickness[0.007]];


     pupils = Graphics[{PointSize[0.015],
                        Point[{0.6+(h/22)(-1)^Round[h],0.5}],
                        Point[{-0.6+(h/22)(-1)^Round[h],0.5}]
                        }];

     Show[body,eyes,mouth,pupils, 
               Axes->False,opts,DisplayFunction->$DisplayFunction]
               
         ]


GalleryOfPortraits[matrixA_List]:=

    Show[GraphicsArray[Table[StoGho[matrixA[[i,j,1]],
                                    matrixA[[i,j,2]],
                               DisplayFunction->Identity],
                               {i,Length[matrixA]},
                               {j,Length[First[matrixA]]}]]]


End[ ]


EndPackage[ ]
