/****************************************************************************
 * 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.46003446747451127000,
       0.97461639460227290000,
       0.58550188866415520000,
       1.07807995028409120000) => (1228,960)
   }










   // Set up our colors - in this case, we effectively have two color tables.
   // The first color tables' entries run from 0 => 360 and they contain
   // shades of blue.  The second color tables' entries run from
   // 360 => 720 and they contain shades of greenish-blue.

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

   // Set up our fractal

   formula {
      z = current;
      x = [0, 0];
      y = [0, 0];
      c = [.563, 0];

      while($count < 100 && magnitude(z) < 2)
      {
         z = z * z - .5 * z + c;
//         x = z * z - .5 * y + c;
         x = z * z - .5 * y + c;
         y = z;
         z = x;
      }

      // $count will be the number of times the while loop above was
      // executed, so fmod($count, 2) will produce 0 if $count was
      // even, 1 if $count was odd.  We multiply that result by 360
      // so what we end up with is:
      //
      // $color = z.degrees;       (if $count was even)
      // $color = z.degrees + 360; (if $count was odd)
      //
      // This is the standard mechanism we use for producing fractals
      // that utilize 2 gradient ranges.  It is also interesting to note
      // that we can easily extend this concept to more than 2 color
      // ranges by defining more gradient sections in our color table and
      // by using a number larger then 2 in fmod($count, 2)

      set_color(degrees(z) + fmod($count, 2) * 360);
   }
}










