/****************************************************************************
 * This formula file or any formula file derived from it cannot be used for
 * commercial purposes or to create hard copy output without the explicit
 * consent of the original author.
 ****************************************************************************/

fractal {

   // Establish the mapping between complex coordinates
   // and display coordinates

   mapping {
      (-0.22950813946773754000,
       -2.57712912024306820000,
       3.70687160199815670000,
       2.60153312544401420000) => (1228,960)
   }

   // Set up our colors - our first set of colors (following define(0))
   // will be a set of yellow shades.  Note that our gradient only
   // spans 72 color entries and we use the repeat(5) command to replicate
   // that gradient 5 times so we get a total of 360 entries.
   // Our second set of colors is a normal gradient of green shades.

   colors {
      define(0){
            gradient(361){
             [204 153 0]
               [255 255 204]
               [204 153 0]
  // [255 255 204]
            }
         
      }
      define(360) {
         gradient(361) {
            [0 51 51]
[153 204 204]
[0 51 51]
           // [102 153 153]
         }
      }

   }

   // Set up our fractal

   formula {
      z = [0, 0];
      c = current;

      while($count < 100 && magnitude(z) < 2)
      {
         if(fmod($count, 4) == 0)
         {
            z = log(c) * cos(z);
            c = sqrt(z * z + c);
         }
         else
         {
            c = log(z) * cos(c);
            z = sqrt(c * c + z);
         }
      }

      // We use a slightly different coloring technique here - we know that:
      //
      // -1 <= cos(magnitude(z))            <= 1, and
      // 0  <= abs(cos(magnitude(z)))       <= 1, then
      // 0  <= abs(cos(magnitude(z))) * 360 <= 360
      //
      // We add degrees(z) to our first value (which will range between 0
      // and 360) thus producing a color index across 0 => 720 (which
      // spans all our defined color values)

      if(fmod(magnitude(z), 2) < .2)
      {
         $color = fmod(magnitude(z), 2) * 1800;
      }
      else
      {
         $color = 360 + abs(cos(radians(c+z))) * 360;
         
      }     
      set_color($color);
   }
}

