home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e032 / 3.ddi / FILES / PROGRAMM.PAK / ARGCOLOR.M < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.1 KB  |  37 lines

  1.  
  2. (*********************************************************************
  3.  
  4.         Adapted from
  5.         Roman E. Maeder: Programming in Mathematica,
  6.         Second Edition, Addison-Wesley, 1991.
  7.  
  8.  *********************************************************************)
  9.  
  10.  
  11. BeginPackage["Graphics`ArgColors`"]
  12.  
  13. ArgColor::usage = "ArgColor[z] gives a color value whose hue is proportional
  14.     to the argument of the complex number z."
  15. ArgShade::usage = "ArgShade[z] gives a gray level proportional
  16.     to the argument of the complex number z."
  17.  
  18. ColorCircle::usage = "ColorCircle[r, (light:1)] gives a color value whose hue
  19.     is proportional to r (mod 2Pi) with lightness light."
  20.  
  21. Begin["`Private`"]
  22.  
  23. ArgColor[z_] := Hue[0, 0, 1] /; z == 0.0
  24. ArgColor[z_] := ColorCircle[ Arg[z] ] /; NumberQ[N[z]]
  25.  
  26. ArgShade[z_] := GrayLevel[1] /; z == 0.0
  27. ArgShade[z_] := GrayLevel[N[(Pi + Arg[z])/(2Pi)] ] /; NumberQ[N[Arg[z]]]
  28.  
  29. ColorCircle[arg_, light_:1.0] := Hue[ N[arg/2/Pi], 1, light ] /; NumberQ[N[arg]]
  30.  
  31. End[]
  32.  
  33. Protect[ArgColor, ArgShade, ColorCircle]
  34.  
  35. EndPackage[]
  36.  
  37.