
(*********************************************************************

        Adapted from
        Roman E. Maeder: Programming in Mathematica,
        Second Edition, Addison-Wesley, 1991.

 *********************************************************************)


BeginPackage["Graphics`ArgColors`"]

ArgColor::usage = "ArgColor[z] gives a color value whose hue is proportional
	to the argument of the complex number z."
ArgShade::usage = "ArgShade[z] gives a gray level proportional
	to the argument of the complex number z."

ColorCircle::usage = "ColorCircle[r, (light:1)] gives a color value whose hue
	is proportional to r (mod 2Pi) with lightness light."

Begin["`Private`"]

ArgColor[z_] := Hue[0, 0, 1] /; z == 0.0
ArgColor[z_] := ColorCircle[ Arg[z] ] /; NumberQ[N[z]]

ArgShade[z_] := GrayLevel[1] /; z == 0.0
ArgShade[z_] := GrayLevel[N[(Pi + Arg[z])/(2Pi)] ] /; NumberQ[N[Arg[z]]]

ColorCircle[arg_, light_:1.0] := Hue[ N[arg/2/Pi], 1, light ] /; NumberQ[N[arg]]

End[]

Protect[ArgColor, ArgShade, ColorCircle]

EndPackage[]

