home *** CD-ROM | disk | FTP | other *** search
/ ftp.xmission.com / 2014.06.ftp.xmission.com.tar / ftp.xmission.com / pub / lists / fractint / archive / v01.n395 < prev    next >
Internet Message Format  |  1999-05-31  |  57KB

  1. From: owner-fractint-digest@lists.xmission.com (fractint-digest)
  2. To: fractint-digest@lists.xmission.com
  3. Subject: fractint-digest V1 #395
  4. Reply-To: fractint-digest
  5. Sender: owner-fractint-digest@lists.xmission.com
  6. Errors-To: owner-fractint-digest@lists.xmission.com
  7. Precedence: bulk
  8.  
  9.  
  10. fractint-digest         Tuesday, June 1 1999         Volume 01 : Number 395
  11.  
  12.  
  13.  
  14.  
  15. ----------------------------------------------------------------------
  16.  
  17. Date: Tue, 01 Jun 1999 02:12:32 +1200
  18. From: "Morgan L. Owens" <packrat@nznet.gen.nz>
  19. Subject: RE: (fractint) Topology of the MandelBrot
  20.  
  21. At 09:29 31/05/99 -0300, you wrote:
  22. >My English is somewhat poor. What is a midgit? The Babylon translator does
  23. >not know it.
  24.  
  25. It ought to; a midgit is a thing (usually a person) that is smaller than
  26. usual. In this case, it refers to the miniature versions of the Mandelbrot
  27. set that are scattered around the main set.
  28.  
  29. MLO
  30.  
  31.  
  32.  
  33. - --------------------------------------------------------------
  34. Thanks for using Fractint, The Fractals and Fractint Discussion List
  35. Post Message:   fractint@lists.xmission.com
  36. Get Commands:   majordomo@lists.xmission.com "help"
  37. Administrator:  twegner@phoenix.net
  38. Unsubscribe:    majordomo@lists.xmission.com "unsubscribe fractint"
  39.  
  40. ------------------------------
  41.  
  42. Date: Mon, 31 May 1999 12:28:47 EDT
  43. From: Damascena@aol.com
  44. Subject: Re: (fractint) Topology of the MandelBrot
  45.  
  46. In a message dated 5/31/99 8:15:48 AM Mountain Daylight Time, 
  47. packrat@nznet.gen.nz writes:
  48.  
  49. >  a midgit is a thing (usually a person) that is smaller than
  50. >  usual.
  51.  
  52. Babylon probably wants the word spelled correctly:
  53.  
  54. midget
  55.  
  56. Dama
  57.  
  58. - --------------------------------------------------------------
  59. Thanks for using Fractint, The Fractals and Fractint Discussion List
  60. Post Message:   fractint@lists.xmission.com
  61. Get Commands:   majordomo@lists.xmission.com "help"
  62. Administrator:  twegner@phoenix.net
  63. Unsubscribe:    majordomo@lists.xmission.com "unsubscribe fractint"
  64.  
  65. ------------------------------
  66.  
  67. Date: 31 May 99 22:11:43 MDT
  68. From: Paul Derbyshire <pderbysh@usa.net>
  69. Subject: (fractint) Fractal source code.
  70.  
  71. Attached below are two source files, which are fairly short.
  72.  
  73. The first, batchm.cc, is a simple C++ source, fully ANSI (I think, if you=
  74.  find
  75. an incompatibility let me know), which generates a Mandelbrot image from
  76. command line parameters (center, mag, and a few more) using either 1 pass=
  77. ,
  78. tesseral, or guessing. It's been tested (in all 3 algorithms, with severa=
  79. l
  80. classic seahorse valley images) and works. The output is a 3 megabyte
  81. "iter.dat" file. This file consists of a 1024x768 array of unsigned 32-bi=
  82. t
  83. integer values, which are iteration values, arrayed first across then dow=
  84. n.
  85. This is raw iteration data, not a meaningful image file format, to be col=
  86. ored
  87. externally. It is also not compressed, so it always takes up exactly 3
  88. megabytes. (4 byte integer times 1024 times 768 is 4 times 1024 times (10=
  89. 24 *
  90. 3/4)) bytes ... or three quarters of 4*1024*1024, which is three quarters=
  91.  of 4
  92. megs, which is 3 megs.)
  93.  
  94. A future revision will allow the output filename to be changed from the
  95. default with a command line parameter and will nix a slight bug.
  96.  
  97. Known bugs: Just one. The occasional image is generated with a few pixels=
  98.  
  99. saved with maxiter+1 as the value. I am not certain how this happens and =
  100. plan
  101. to investigate. As a result, the maximum value in the iters.dat file isn'=
  102. t
  103. always the value you color black to fill the lake.
  104.  
  105. The program uses long double arithmetic (whose precision depends on the
  106. machine architecture compiled on). It should be as capable of zooming as
  107. Fractint sans arbitrary precision (e.g. Fractint 18.21 or Winfract).
  108.  
  109. It only does Mandelbrots. And it only does them plainly, with the lake fi=
  110. lled
  111. in as the set maxiter value.
  112.  
  113. There is periodicity checking by the way. The algorithm is a variant of a=
  114.  
  115. classic one and probably similar to Fractint's.
  116.  
  117.  
  118. The second program is srenderm.cc. It requires the Allegro graphics libra=
  119. ry or
  120. something compatible. It should work with winalleg, dos allegro, and x wi=
  121. ndows
  122. allegro. It reads "iter.dat" in the format output by batchm and displays =
  123. it
  124. onscreen in the highest-bit-depth 1024x768 video mode it can autodetect. =
  125. (A
  126. high-color, i.e. 15 or more bits, 1024x768 mode *must* be available.)
  127.  
  128. The iterations are mapped between the minimum and maximum iteration to a
  129. simple golden color scheme. The M-set itself is black (unless the
  130. afore-mentioned batchm bug struck, in which case it will be white with
  131. scattered black pixels adjoining).
  132.  
  133. A future revision will allow specifying the input file, saving the output=
  134.  in
  135. =2Epcx format (to any input filename), optionally doing a render and save=
  136.  
  137. without invoking graphics, and allow editing of color scheme, loading, an=
  138. d
  139. saving in a manner resembling Ultra Fractal. I may also include an option=
  140.  for
  141. rendering to a greyscale, applying some log function to the input in the
  142. process, and outputting a greyscale TGA of the kind ray tracers can use f=
  143. or
  144. height-fields.
  145.  
  146. I may also develop a third program, pure ANSI with no special libraries
  147. needed, for converting the batchm output into a triangle mesh of chosen l=
  148. evel
  149. of detail (up to 1024x768x2 triangles) saved in a format ray tracers can =
  150. use.
  151.  
  152. Both programs handle errors rather ungracefully, by immediately terminati=
  153. ng
  154. with a terse but meaningful error message. (Some bug with killing the gfx=
  155.  mode
  156. seems to suppress these with srenderm, which I shall fix soon.)
  157.  
  158.  
  159.  
  160.  
  161. - ---
  162.  
  163. Here is the batchm.cc file, with comments explaining command line options=
  164.  and
  165. some of the internals.
  166.  
  167.  
  168.  
  169. // batchm.cc
  170. // (c) 1999 PGD. Open Source.
  171.  
  172. // Very simple batch Mandelbrot program.
  173. // Types: just Mandelbrot.
  174. // Algorithms: just periodicity checking and either 1-pass, tesseral, or =
  175. solid
  176. guessing.
  177. // Options: 1, t, or g for algorithm, and option to determine "iteration
  178. resolution".
  179. // Interface: command line.
  180.  
  181. // Command line consists of center and mag (long doubles), iteration
  182. resolution control, and optional switches.
  183. // Examples: foo.exe     (basic Mandelbrot)
  184. // foo.exe  -.75 0  10     (seahorse valley zoom)
  185. // foo.exe  -.75 0  10  5000   (Maxiter 5000 instead of default 2000)
  186. // foo.exe  -.75 0  10  5000  30   (Now iterations resolved individually =
  187. from
  188. 1 to 30, to nearest even number from 31 to 90, etc.)
  189.  
  190. // foo.exe [real-center-coordinate] [imag-center-coordinate] [magnificati=
  191. on]
  192. [iteration-resolution] [switches]
  193.  
  194. // Anything before the first switch is regarded as the first, first and
  195. second, first, second, and third, or first, second, third,
  196. // and fourth of the numerical parameters.
  197.  
  198. // Switches: /1, /t, /g for algorithm.
  199.  
  200. // Output: Either an iter.dat file or an error message from the following=
  201. :
  202.  
  203. // * Invalid switch        Command line has an unrecognized switch.
  204. // * Extra parameter       Command line has an extra non-switch item.
  205. // * Ill-formed parameter  Command line has a parameter that is not a num=
  206. ber
  207. or else is not an integer
  208. //                         but should be an integer.
  209. // * Various libc file I/O errors to do with problems with writing iter.d=
  210. at
  211.  
  212. // On-screen a successful run will display a progress indicator, outputin=
  213. g
  214. pixels-done/pixels-in-image every thousand pixels.
  215.  
  216. // Format of iter.dat: across-then-down 1024x768 array of iter values. Ea=
  217. ch
  218. value is a big-endian 32-bit integer.
  219. // File size is thus 3 megabytes ... post-process it and then archive/del=
  220. ete!
  221.  
  222. // Defaults: passes=3D1, center at (0, 0), magnification 1 (which means i=
  223. mage is
  224. 4 units by 3), maxiter 2000, and
  225. // iterations resolved as follows: individual -- 1 through 50. Nearest ev=
  226. en --
  227. 51 through 150 (as 52, 54, ... , 150).
  228. // Nearest multiple of 4 -- 151 through 350, etc.
  229.  
  230. // Math used: long doubles everywhere.
  231.  
  232. // For batchfile use, the errorlevels returned are:
  233. // 0 -- Normal exit.
  234. // 1 -- Incorrect cmdline.
  235. // 2 -- File I/O error with output.
  236. // 3 -- Miscellaneous error.
  237. // 255 (-1) -- Crashed (should not happen).
  238.  
  239.  
  240.  
  241. // Compilation:
  242.  
  243. // This is portable ANSI C++. Compile this into an object, link with libc=
  244.  into
  245. an executable, and you are off.
  246.  
  247. // For best results compile with latest egcs, with the best optimization
  248. options for your cpu. The inner loop should run
  249. // fast and tight in FP registers. There is no abort key -- if it is taki=
  250. ng
  251. forever you need to kill the process
  252. // from the operating system.
  253.  
  254.  
  255. // Get stdio to perform file output. This is largely 'C' code with only a=
  256.  few
  257. C++ features. We mainly want C++
  258. // for its pass-by-reference and tight type-checking.
  259. #include <stdio.h>
  260.  
  261.  
  262. // Convienient shorthands.
  263. typedef long double real;
  264. typedef unsigned long iter;
  265.  
  266.  
  267. // Statically allocate 3 megabyte array to store iteration values.
  268. iter iter_data[768][1024];  // Y then X reduces cache misses with small c=
  269. aches
  270. using passes=3D1 and passes=3Dg.
  271.  
  272.  
  273.  
  274. // Keep track of options.
  275.  
  276. // Algorithm for pixel 'coloring'.
  277. enum alg { one, tess, guess };
  278. alg current_alg =3D one;
  279.  
  280. // Periodicity checking sensitivity.
  281. real per_check_sens;
  282. const real per_check_s_base =3D 0.0000001;
  283.  
  284. // Bailout radius squared.
  285. const real bail_radius_squared =3D 4;
  286.  
  287. // Center and magnification.
  288. real center_real =3D -0.75;
  289. real center_imag =3D 0;
  290. real mag =3D 1;
  291.  
  292. // Dimensions at magnification 1.
  293. const real xmag1 =3D 4;
  294. const real ymag1 =3D 3;
  295.  
  296. // How frequently (in pixels) to report progress.
  297. const long progress_freq =3D 1024;  // Every row in passes=3D1; 768 times=
  298. =2E
  299.  
  300.  
  301. // Progress report stuff.
  302. long pixels_done, next_report;
  303.  
  304. // Iteration resolution feature (used to enhance passes=3Dt, g with detai=
  305. led
  306. fractals; not used with passes=3D1).
  307. iter ires_change =3D 50;
  308.  
  309. // Maxiter.
  310. iter maxiter =3D 2000;
  311.  
  312. // Miniter.
  313. iter miniter; // Value is determined by find_lowest_iter().
  314.  
  315. // Tesseral stop threshold.
  316. const int min_tess_box_size =3D 4;
  317.  
  318. // Guessing initial stepsize.
  319. const int guess_size =3D 16;
  320.  
  321.  
  322. // Function prototypes.
  323.  
  324.  
  325. // Input-related.
  326.  
  327. // Command line processor. Takes argc, argv, returns true if all is well,=
  328.  
  329. false if error.
  330. // Outputs error message to stderr itself on failure. On success leaves
  331. results stored in above globals.
  332. bool process_cmdline (int argc, const char **argv);
  333.  
  334.  
  335.  
  336. // Output-related.
  337.  
  338. // Outputs an unsigned long to a FILE * in big-endian format.
  339. void write_iter (FILE *dest, iter value);
  340.  
  341. // Outputs the iter_data array to iter.dat. Indiscriminately overwrites. =
  342. Bool
  343. has same meaning as for process_cmdline.
  344. bool output_iters (void);
  345.  
  346.  
  347. // Calculation-related.
  348.  
  349. // Calculates absolute of a real.
  350. inline real ldabs (real x) { return (x<0) ? -x : x; }
  351.  
  352. // Calculates one pixel. Input: two reals, the x and y coordinates. Outpu=
  353. t: a
  354. long, the iteration count (raw).
  355. iter calculate_pixel (real x, real y);
  356.  
  357. // Calculates an adjusted iter from a raw iter based on ires_change.
  358. inline iter adjust_iter (iter i);
  359.  
  360. // Calculates an adjusted pixel.
  361. inline iter calculate_adjusted_pixel (real x, real y) { return
  362. adjust_iter(calculate_pixel(x, y)); }
  363.  
  364. // Find the minimum iteration.
  365. void find_lowest_iter (void);
  366.  
  367. // Calculates the fractal.
  368. void do_pixel (int sx, int sy);
  369. void do_adjusted_pixel (int sx, int sy);
  370. void one_pass_mandel (void);
  371. void tesseral_mandel (int blockx, int blocky, int xblocksize, int yblocks=
  372. ize);
  373. void guessing_mandel (int size);
  374. void calculate_mandel (void);
  375.  
  376. // Translates a pixel coordinate into a complex number, using given
  377. center-mag. Adds a small jitter (+/-0.5) to
  378. // both coordinates to prevent aliasing defects.
  379. void make_coords (int sx, int sy, real &x, real &y);
  380.  
  381.  
  382.  
  383.  
  384. // Main program.
  385. int main (int argc, const char **argv) {
  386.   printf("\nRunning batchm.\n");
  387.   if (!process_cmdline(argc, argv)) {
  388.     printf("\nThere were some errors.\n\n");
  389.     return 1;
  390.   }
  391.   calculate_mandel();
  392.   if (!output_iters()) {
  393.     printf("\nThere were some errors.\n\n");
  394.     return 2;
  395.   }
  396.   printf("\nReturning from successful batchm run.\n\n");
  397.   return 0;
  398. }
  399.  
  400.  
  401.  
  402. // Input-related.
  403.  
  404. // Command line processor. Takes argc, argv, returns true if all is well,=
  405.  
  406. false if error.
  407. // Outputs error message to stderr itself on failure. On success leaves
  408. results stored in above globals.
  409.  
  410. bool process_cmdline (int argc, const char **argv) {
  411.   bool found_switch =3D false;
  412.   const char *current;
  413.   char c;
  414.   int working_on_parm =3D 1;
  415.   printf ("\nProcessing input.\n");
  416.   for (int i=3D1; i<argc; ++i) {
  417.     current=3Dargv[i];
  418.     if (found_switch) {
  419.       if (current[0] !=3D '/') {
  420.         fprintf (stderr, "Error: Extra parameter %s after switches.\n",
  421. current);
  422.         return false;
  423.       }
  424.     }
  425.     if (current[0] =3D=3D '/') {
  426.       // Found a switch.
  427.       c =3D current[1];
  428.       if (current[2] !=3D 0) {
  429.         fprintf (stderr, "Error: Invalid switch %s.", current);
  430.         return false;
  431.       }
  432.       switch (c) {
  433.         case '1':
  434.           current_alg =3D one; break;
  435.         case 't':
  436.           current_alg =3D tess; break;
  437.         case 'g':
  438.           current_alg =3D guess; break;
  439.         default:
  440.           fprintf (stderr, "Error: Invalid switch %s.", current);
  441.           return false;
  442.       }
  443.       // For now, only one switch is needed, to set algorithm; any others=
  444.  are
  445. redundant.
  446.       // Issue a warning if this is a second.
  447.       if (found_switch) fprintf (stderr, "Warning: Redundant algorithm
  448. switch.\n");
  449.       found_switch =3D true;
  450.     } else {
  451.       // Okay, we are working on some sort of parameter.
  452.       switch (working_on_parm) {
  453.         case 1:
  454.           // Center real. Is a real.
  455.           if (1 !=3D sscanf(current, "%Lf", ¢er_real)) {
  456.             fprintf(stderr, "Error: Ill-formed center real coordinate %s =
  457. (not
  458. a real number).", current);
  459.             return false;
  460.           }
  461.           printf ("Center x set to %Lf.\n", center_real);
  462.           break;
  463.         case 2:
  464.           // Center imag. Is a real.
  465.           if (1 !=3D sscanf(current, "%Lf", ¢er_imag)) {
  466.             fprintf(stderr, "Error: Ill-formed center real coordinate %s =
  467. (not
  468. a real number).", current);
  469.             return false;
  470.           }
  471.           printf ("Center y set to %Lf.\n", center_imag);
  472.           break;
  473.         case 3:
  474.           // Magnification. Is a real.
  475.           if (1 !=3D sscanf(current, "%Lf", &mag)) {
  476.             fprintf(stderr, "Error: Ill-formed center real coordinate %s =
  477. (not
  478. a real number).", current);
  479.             return false;
  480.           }
  481.           printf ("Magnification set to %Lf.\n", mag);
  482.           break;
  483.         case 4:
  484.           // Maxiter. Is an integer (unsigned).
  485.           if (1 !=3D sscanf(current, "%lu", &maxiter)) {
  486.             fprintf(stderr, "Error: Ill-formed center real coordinate %s =
  487. (not
  488. a real number).", current);
  489.             return false;
  490.           }
  491.           printf ("Maxiter set to %lu.\n", maxiter);
  492.           break;
  493.         case 5:
  494.           // Iteration resolution parameter. Is an integer (unsigned).
  495.           if (1 !=3D sscanf(current, "%lu", &ires_change)) {
  496.             fprintf(stderr, "Error: Ill-formed center real coordinate %s =
  497. (not
  498. a real number).", current);
  499.             return false;
  500.           }
  501.           printf ("Iteration resolution parameter set to %lu.\n",
  502. ires_change);
  503.           break;
  504.         default:
  505.           fprintf (stderr, "Error: Extra sixth parameter %s.\n", current)=
  506. ;
  507.           return false;
  508.       }
  509.       ++working_on_parm;
  510.     }
  511.   }
  512.   if (working_on_parm =3D=3D 6 && current_alg =3D=3D one) {
  513.     // The specification of a value for ires_change with passes=3D1 gener=
  514. ates a
  515. warning as ires_change is ignored with
  516.     // passes=3D1.
  517.     fprintf (stderr, "Warning: Specification of iter res parameter unused=
  518.  with
  519. passes=3D1.");
  520.   }
  521.   return true;
  522. }
  523.  
  524.  
  525.  
  526.  
  527.  
  528. // Output-related.
  529.  
  530. // Outputs an unsigned long to a FILE * in big-endian format.
  531.  
  532. void write_iter (FILE *dest, iter value) {
  533.   fputc((value & 0xff000000ul) >> 24, dest);
  534.   fputc((value & 0x00ff0000ul) >> 16, dest);
  535.   fputc((value & 0x0000ff00ul) >> 8, dest);
  536.   fputc(value & 0x000000fful, dest);
  537. }
  538.  
  539.  
  540.  
  541. // Outputs the iter_data array to iter.dat. Indiscriminately overwrites. =
  542. Bool
  543. has same meaning as for process_cmdline.
  544.  
  545. bool output_iters (void) {
  546.   printf ("\nOutputing iterations data.\n");
  547.   FILE *of;
  548.   of =3D fopen("iter.dat","wb");
  549.   if (!of) {
  550.     perror("Error: Filesystem error writing output.\n");
  551.     return false;
  552.   }
  553.   for (int y=3D0; y<768; ++y) {
  554.     for (int x=3D0; x<1024; ++x) {
  555.       write_iter(of, iter_data[y][x]);
  556.     }
  557.   }
  558.   if (ferror(of)) {
  559.     perror("Error: Filesystem error writing output.\n");
  560.     return false;
  561.   }
  562.   if (fclose(of)) {
  563.     perror("Error: Filesystem error writing output.\n");
  564.     return false;
  565.   }
  566.   return true;
  567. }
  568.  
  569.  
  570.  
  571.  
  572.  
  573. // Calculation-related.
  574.  
  575. // Calculates one pixel. Input: two reals, the x and y coordinates. Outpu=
  576. t: a
  577. long, the iteration count (raw).
  578.  
  579. iter calculate_pixel (real x, real y) {
  580.   real zx =3D 0;
  581.   real zy =3D 0;
  582.   real zx2 =3D 0;
  583.   real zy2 =3D 0;
  584.   real zzx =3D 0;
  585.   real zzy =3D 0;
  586.   real zzx2 =3D 0;
  587.   real zzy2 =3D 0;
  588.   real dst;
  589.   iter i =3D 0;
  590.   int mod16 =3D 0;
  591.  
  592.   while (zx2+zy2 <=3D bail_radius_squared && i < maxiter) {
  593.     if (mod16 =3D=3D 16) {
  594.       mod16 =3D 0;
  595.       zzy =3D 2*zzx*zzy + y;
  596.       zzx =3D zzx2 - zzy2 + x;
  597.       zzx2 =3D zzx*zzx;
  598.       zzy2 =3D zzy*zzy;
  599.     }
  600.     ++mod16;
  601.     zy =3D 2*zx*zy + y;
  602.     zx =3D zx2 - zy2 + x;
  603.     zx2 =3D zx*zx;
  604.     zy2 =3D zy*zy;
  605.     ++i;
  606.     dst =3D ldabs(zx - zzx) + ldabs(zy - zzy);
  607.     if (dst < per_check_sens) i =3D maxiter;     // Periodicity checking =
  608. caught
  609. a cycle.
  610.   }
  611.   =
  612.  
  613.   return i;
  614. }
  615.  
  616.  
  617.  
  618. // Translates a pixel coordinate into a complex number, using given
  619. center-mag. Adds a small jitter (+/-0.5) to
  620. // both coordinates to prevent aliasing defects.
  621.  
  622. void make_coords (int sx, int sy, real &x, real &y) {
  623.   real dx, dy;
  624.   dx =3D (((real)sx - (real)512) / (real)1024) * xmag1 / mag;
  625.   dy =3D (((real)384 - (real)sy) / (real)768) * ymag1 / mag;
  626.   x =3D center_real + dx;
  627.   y =3D center_imag + dy;
  628. }
  629.  
  630.  
  631.  
  632. // Calculates an adjusted iter from a raw iter based on ires_change.
  633. inline iter adjust_iter (iter i) {
  634.   iter result =3D i - miniter;
  635.   iter r1 =3D result;
  636.   int nearest_mod =3D 1;
  637.   int nmh =3D 1;
  638.   int nm2 =3D 1;
  639.   int r_mod;
  640.   while (r1 > ires_change) {
  641.     nmh =3D nearest_mod;
  642.     nearest_mod *=3D 2;
  643.     ++nm2;
  644.     r1 -=3D ires_change;
  645.     r1 /=3D 2;
  646.   }
  647.   if (nearest_mod =3D=3D 1) return result;
  648.   // Compute result to nearest multiple of nearest_mod.
  649.   r_mod =3D result % nearest_mod;
  650.   result >>=3D nm2;   // Same as /=3D nearest_mod.
  651.   if (r_mod >=3D nmh) ++result; // nmh is 1/2 nearest_mod so result is to=
  652.  be
  653. rounded up.
  654.   result <<=3D nm2;   // Same as *=3D nearest_mod. We have now rounded do=
  655. wn or up,
  656. depending.
  657.   return result;
  658. }
  659.  
  660.  
  661.  
  662. // Find the minimum iteration.
  663. void find_lowest_iter (void) {
  664.   // We compute the image boundary, and thereby locate the minimum iterat=
  665. ion.
  666. If necessary we retroactively adjust
  667.   // the computed iters.
  668.  
  669.   int sx, sy;
  670.   real x, y;
  671.   iter i;
  672.  
  673.   miniter =3D maxiter;
  674.   printf ("\nFinding minimum iteration and doing image border.\n");
  675.  
  676.   // Top edge.
  677.   sy =3D 0;
  678.   for (sx =3D 0; sx < 1024; ++sx) {
  679.     make_coords(sx, sy, x, y);
  680.     i =3D calculate_pixel(x, y);
  681.     if (i < miniter) miniter =3D i;
  682.     iter_data[sy][sx] =3D i;
  683.   }
  684.   printf ("Top edge done.\n");
  685.  
  686.   // Bottom edge.
  687.   sy =3D 767;
  688.   for (sx =3D 0; sx < 1024; ++sx) {
  689.     make_coords(sx, sy, x, y);
  690.     i =3D calculate_pixel(x, y);
  691.     if (i < miniter) miniter =3D i;
  692.     iter_data[sy][sx] =3D i;
  693.   }
  694.   printf ("Bottom edge done.\n");
  695.  
  696.   // Left edge.
  697.   sx =3D 0;
  698.   for (sy =3D 1; sy < 767; ++sy) {  // Skip corners, already done.
  699.     make_coords(sx, sy, x, y);
  700.     i =3D calculate_pixel(x, y);
  701.     if (i < miniter) miniter =3D i;
  702.     iter_data[sy][sx] =3D i;
  703.   }
  704.   printf ("Left edge done.\n");
  705.  
  706.   // Right edge.
  707.   sx =3D 1023;
  708.   for (sy =3D 1; sy < 767; ++sy) {  // Skip corners, already done.
  709.     make_coords(sx, sy, x, y);
  710.     i =3D calculate_pixel(x, y);
  711.     if (i < miniter) miniter =3D i;
  712.     iter_data[sy][sx] =3D i;
  713.   }
  714.   printf ("Right edge done.\n");
  715.  
  716.   printf ("Minimum iteration is %ld.\n", miniter);
  717.   if (current_alg =3D=3D one) return;
  718.   printf ("Adjusting edge iters.\n");
  719.  
  720.   // Top edge.
  721.   sy =3D 0;
  722.   for (sx =3D 0; sx < 1024; ++sx) {
  723.     iter_data[sy][sx] =3D adjust_iter(iter_data[sy][sx]);    =
  724.  
  725.   }
  726.  
  727.   // Bottom edge.
  728.   sy =3D 767;
  729.   for (sx =3D 0; sx < 1024; ++sx) {
  730.     iter_data[sy][sx] =3D adjust_iter(iter_data[sy][sx]);    =
  731.  
  732.   }
  733.  
  734.   // Left edge.
  735.   sx =3D 0;
  736.   for (sy =3D 1; sy < 767; ++sy) {  // The corners are already done.
  737.     iter_data[sy][sx] =3D adjust_iter(iter_data[sy][sx]);    =
  738.  
  739.   }
  740.  
  741.   // Top edge.
  742.   sx =3D 1023;
  743.   for (sy =3D 1; sy < 767; ++sy) {  // The corners are already done.
  744.     iter_data[sy][sx] =3D adjust_iter(iter_data[sy][sx]);    =
  745.  
  746.   }
  747.  
  748.   printf("Done adjusting edge iters.\n");
  749. }
  750.  
  751.  
  752.  
  753. void do_pixel (int sx, int sy) {
  754.   real x, y;
  755.   if (iter_data[sy][sx] =3D=3D 0) {
  756.     make_coords(sx, sy, x, y);
  757.     iter_data[sy][sx] =3D calculate_pixel(x, y);
  758.     ++pixels_done;
  759.     if (pixels_done >=3D next_report) {
  760.       printf ("%06ld/786432\n",pixels_done);
  761.       next_report=3D(pixels_done/progress_freq)*progress_freq + progress_=
  762. freq;
  763.     }
  764.   }
  765. }
  766.  
  767. void do_adjusted_pixel (int sx, int sy) {
  768.   real x, y;
  769.   if (iter_data[sy][sx] =3D=3D 0) {
  770.     make_coords(sx, sy, x, y);
  771.     iter_data[sy][sx] =3D calculate_adjusted_pixel(x, y);
  772.     ++pixels_done;
  773.     if (pixels_done >=3D next_report) {
  774.       printf ("%06ld/786432\n",pixels_done);
  775.       next_report=3D(pixels_done/progress_freq)*progress_freq + progress_=
  776. freq;
  777.     }
  778.   }
  779. }
  780.  
  781. void fill_pixel (int sx, int sy, int i) {
  782.   if (iter_data[sy][sx] =3D=3D 0) {
  783.     iter_data[sy][sx] =3D i;
  784.     ++pixels_done;
  785.     if (pixels_done >=3D next_report) {
  786.       printf ("%06ld/786432\n",pixels_done);
  787.       next_report=3D(pixels_done/progress_freq)*progress_freq + progress_=
  788. freq;
  789.     }
  790.   }
  791. }
  792.  
  793.  
  794. // Calculates the fractal.
  795.  
  796. void calculate_mandel (void) {
  797.   printf("\nComputing iter data.\n");
  798.   per_check_sens =3D per_check_s_base/mag;
  799.   find_lowest_iter();
  800.   printf("\nComputing body.\n");
  801.   printf("003580/786432\n");
  802.   pixels_done=3D3580;
  803.   next_report=3D(pixels_done/progress_freq)*progress_freq + progress_freq=
  804. ;
  805.   switch(current_alg) {
  806.     case one:
  807.       one_pass_mandel(); break;
  808.     case tess:
  809.       tesseral_mandel(0, 0, 1023, 767); break;
  810.     case guess:
  811.       guessing_mandel(guess_size);
  812.   }
  813.   if (next_report !=3D 786432 + progress_freq) {
  814.     printf("786432/786432\n");
  815.   }
  816.   printf("\nCalculation complete.\n");
  817. }
  818.  
  819.  
  820. void one_pass_mandel (void) {
  821.   for (int sy=3D0; sy<768; ++sy) {
  822.     for (int sx=3D0; sx<1024; ++sx) {
  823.       do_pixel(sx, sy);
  824.     }
  825.   }
  826. }
  827.  
  828.  
  829. void tesseral_mandel (int blockx, int blocky, int xblocksize, int yblocks=
  830. ize)
  831. {
  832.   iter cmp;
  833.   bool subdivide =3D false;
  834.   int sx, sy;
  835.   int midx, midy;
  836.   int right =3D blockx + xblocksize;
  837.   int bottom =3D blocky + yblocksize;
  838.   do_adjusted_pixel(blockx, blocky);
  839.   cmp =3D iter_data[blocky][blockx];
  840.  
  841.   // Top edge.
  842.   sy =3D blocky;
  843.   for (sx =3D blockx; sx <=3D right; ++sx) {
  844.     do_adjusted_pixel(sx, sy);
  845.     if (cmp !=3D iter_data[sy][sx]) subdivide =3D true;
  846.   }
  847.  
  848.   // Bottom edge.
  849.   sy =3D bottom;
  850.   for (sx =3D blockx; sx <=3D right; ++sx) {
  851.     do_adjusted_pixel(sx, sy);
  852.     if (cmp !=3D iter_data[sy][sx]) subdivide =3D true;
  853.   }
  854.  
  855.   // Left edge.
  856.   sx =3D blockx;
  857.   for (sy =3D blocky + 1; sy < bottom; ++sy) {  // The corners are alread=
  858. y done.
  859.     do_adjusted_pixel(sx, sy);
  860.     if (cmp !=3D iter_data[sy][sx]) subdivide =3D true;
  861.   }
  862.  
  863.   // Right edge.
  864.   sx =3D right;
  865.   for (sy =3D blocky + 1; sy < bottom; ++sy) {  // The corners are alread=
  866. y done.
  867.     do_adjusted_pixel(sx, sy);
  868.     if (cmp !=3D iter_data[sy][sx]) subdivide =3D true;
  869.   }
  870.  
  871.   if (subdivide) {
  872.     if (xblocksize <=3D min_tess_box_size) {
  873.       // Do inside of box pixel by pixel.
  874.       for (sy =3D blocky + 1; sy < bottom; ++sy) {
  875.         for (sx =3D blockx + 1; sx < right; ++sx) {
  876.           do_adjusted_pixel(sx, sy);
  877.         }
  878.       }
  879.       return;
  880.     }
  881.     if (xblocksize >=3D yblocksize) {
  882.       midx =3D (blockx + right)/2;
  883.       tesseral_mandel(blockx, blocky, midx - blockx + 1, yblocksize);
  884.       tesseral_mandel(midx, blocky, right - midx, yblocksize);
  885.       return;
  886.     }
  887.     midy =3D (blocky + bottom)/2;
  888.     tesseral_mandel(blockx, blocky, xblocksize, midy - blocky + 1);
  889.     tesseral_mandel(blockx, midy, xblocksize, bottom - midy);
  890.     return;
  891.   }
  892.   // Fill inside of box.
  893.   for (sy =3D blocky + 1; sy < bottom; ++sy) {
  894.     for (sx =3D blockx + 1; sx < right; ++sx) {
  895.       fill_pixel(sx, sy, cmp);
  896.     }
  897.   }
  898. }
  899.  
  900.  
  901. void guessing_mandel (int size) {
  902.   int bx, by, sx, sy;
  903.   iter cmp;
  904.   int s2 =3D size - 1;
  905.   for (by =3D 0; by < 768; by +=3D size) {
  906.     for (bx =3D 0; bx < 1024; bx +=3D size) {
  907.       // Check if box is not filled.
  908.       if (size=3D=3D2 || iter_data[by][bx + 1] =3D=3D 0) {
  909.         // Compute box corners.
  910.         do_adjusted_pixel(bx, by);
  911.         do_adjusted_pixel(bx + s2, by);
  912.         do_adjusted_pixel(bx, by + s2);
  913.         do_adjusted_pixel(bx + s2, by + s2);
  914.         cmp =3D iter_data[by][bx];
  915.         if (iter_data[by][bx + s2] =3D=3D cmp && iter_data[by + s2][bx] =3D=
  916. =3D cmp &&
  917. iter_data[by + s2][bx + s2] =3D=3D cmp) {
  918.           // Fill inside of box.
  919.           for (sy =3D by; sy < by + size; ++sy) {
  920.             for (sx =3D bx; sx < bx + size; ++sx) {
  921.               fill_pixel(sx, sy, cmp);
  922.             }
  923.           }
  924.         }
  925.       }
  926.     }
  927.   }
  928.   if (size>2) guessing_mandel(size/2);
  929. }
  930.  
  931.  
  932.  
  933.  
  934.  
  935. - ---
  936.  
  937. Here is the srenderm.cc file. It has no command line options as yet. Run =
  938. it
  939. and get an error of or a gfx screen. After
  940. admiring the fractal hit any key to kill gfx and exit to the OS.
  941.  
  942.  
  943.  
  944. // srenderm.cc
  945. // (c) 1999 PGD. Open Source.
  946.  
  947. // Simple Mandelbrot data renderer.
  948.  
  949. // Allegro program, loads 1024x768x24 bit gfx mode and iter.dat file, out=
  950. puts
  951. // on video screen the fractal. Coloring is from black at miniter to dark=
  952.  red
  953. at 20% to yellow at 80% to white at 100%.
  954. // Maxiter is colored black.
  955.  
  956.  
  957.  
  958. #include <stdio.h>
  959. #include <allegro.h>
  960.  
  961.  
  962.  
  963. typedef unsigned long iter;
  964.  
  965. iter iter_data[768][1024];
  966. iter miniter, maxiter, difiter;
  967. bool in_gfx =3D false;
  968.  
  969. void do_allegro_error (void);
  970. void do_stdio_error (void);
  971. void do_eof_error (void);
  972. bool startup (void);
  973. bool read_iter_value (iter &i, FILE *f);
  974. bool load_data (void);
  975. void render_data (void);
  976. int get_color_for_iter (iter i);
  977. void wait_for_exit (void);
  978.  
  979.  
  980. int main (void) {
  981.   if (!startup()) return 1;
  982.   render_data();
  983.   wait_for_exit();
  984.   return 0;
  985. }
  986.  
  987.  
  988. void do_allegro_error (void) {
  989.   if (in_gfx) { set_gfx_mode (GFX_TEXT,80,25,0,0); }
  990.   fprintf(stderr, "Error: %s.\n", allegro_error);
  991. }
  992.  
  993.  
  994. void do_stdio_error (void) {
  995.   if (in_gfx) { set_gfx_mode (GFX_TEXT,80,25,0,0); }
  996.   perror("Error:");
  997. }
  998.  
  999.  
  1000. void do_eof_error (void) {
  1001.   if (in_gfx) { set_gfx_mode (GFX_TEXT,80,25,0,0); }
  1002.   fprintf(stderr, "Unexpected EOF.\n");
  1003. }
  1004.  
  1005.  
  1006. bool startup (void) {
  1007.   if (allegro_init()) { do_allegro_error(); return false; }
  1008.   if (install_keyboard()) { do_allegro_error(); return false; }
  1009.   set_color_depth(32);
  1010.   if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0)) {
  1011.     set_color_depth(24);
  1012.     if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0)) {
  1013.       set_color_depth(16);
  1014.       if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0)) {
  1015.         set_color_depth(15);
  1016.         if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0)) {
  1017.           do_allegro_error(); return false;
  1018.         }
  1019.       }
  1020.     }
  1021.   }
  1022.   return load_data();
  1023. }
  1024.  
  1025.  
  1026. bool read_iter_value (iter &i, FILE *f) {
  1027.   int j;
  1028.   j =3D fgetc(f);
  1029.   if (j =3D=3D EOF) { do_eof_error(); return false; }
  1030.   i =3D j << 24;
  1031.   j =3D fgetc(f);
  1032.   if (j =3D=3D EOF) { do_eof_error(); return false; }
  1033.   i +=3D j << 16;
  1034.   j =3D fgetc(f);
  1035.   if (j =3D=3D EOF) { do_eof_error(); return false; }
  1036.   i +=3D j << 8;
  1037.   j =3D fgetc(f);
  1038.   if (j =3D=3D EOF) { do_eof_error(); return false; }
  1039.   i +=3D j;
  1040.   return true;
  1041. }
  1042.  
  1043.  
  1044. bool load_data (void) {
  1045.   FILE *f;
  1046.   iter i;
  1047.   miniter =3D 0;
  1048.   --miniter; // Should wrap to maximum value.
  1049.   maxiter =3D 0;
  1050.   f =3D fopen("iter.dat","rb");
  1051.   if (!f) { do_stdio_error(); return false; }
  1052.   for (int y=3D0; y<768; ++y) {
  1053.     for (int x=3D0; x<1024; ++x) {
  1054.       if (!read_iter_value(i, f)) return false;
  1055.       iter_data[y][x] =3D i;
  1056.       if (i < miniter) miniter =3D i;
  1057.       if (i > maxiter) maxiter =3D i;
  1058.     }
  1059.   }
  1060.   if (ferror(f)) { do_stdio_error(); return false; }
  1061.   if (fclose(f)) { do_stdio_error(); return false; }
  1062.   difiter =3D maxiter - miniter;
  1063.   return true;
  1064. }
  1065.  
  1066.  
  1067. void render_data (void) {
  1068.   iter i;
  1069.   int col;
  1070.   int white =3D makecol(255, 255, 255);
  1071.   for (int y=3D0; y<768; ++y) {
  1072.     hline(screen, 0, y, 1023, white);
  1073.     for (int x=3D0; x<1024; ++x) {
  1074.       i =3D iter_data[y][x];
  1075.       col =3D get_color_for_iter(i);
  1076.       putpixel(screen, x, y, col);
  1077.     }
  1078.   }
  1079. }
  1080.  
  1081.  
  1082. int get_color_for_iter (iter i) {
  1083.   if (i =3D=3D maxiter) return makecol(0, 0, 0);
  1084.   long double d =3D i;
  1085.   d -=3D miniter;
  1086.   d /=3D difiter;
  1087.   int r, g, b;
  1088.   if (d<0.002) {
  1089.     d *=3D 500;
  1090.     d *=3D 96;
  1091.     r =3D (int)d;
  1092.     return makecol(r, 0, 0);
  1093.   }
  1094.   if (d<0.152) {
  1095.     d -=3D 0.002;
  1096.     d /=3D 0.15;
  1097.     r =3D 96 + (int)(d*160);
  1098.     g =3D (int)(d*256);
  1099.     return makecol(r, g, 0);
  1100.   }
  1101.   d -=3D 0.152;
  1102.   d /=3D 0.848;
  1103.   d *=3D 256;
  1104.   b =3D (int)d;
  1105.   return makecol(255, 255, b);
  1106. }
  1107.  
  1108.  
  1109. void wait_for_exit (void) {
  1110.   while (keypressed()) readkey();
  1111.   while (!keypressed());
  1112.   set_gfx_mode (GFX_TEXT,80,25,0,0);
  1113. }
  1114.  
  1115. ____________________________________________________________________
  1116. Get free e-mail and a permanent address at http://www.netaddress.com/?N=3D=
  1117. 1
  1118.  
  1119. - --------------------------------------------------------------
  1120. Thanks for using Fractint, The Fractals and Fractint Discussion List
  1121. Post Message:   fractint@lists.xmission.com
  1122. Get Commands:   majordomo@lists.xmission.com "help"
  1123. Administrator:  twegner@phoenix.net
  1124. Unsubscribe:    majordomo@lists.xmission.com "unsubscribe fractint"
  1125.  
  1126. ------------------------------
  1127.  
  1128. Date: 31 May 99 22:20:57 MDT
  1129. From: Paul Derbyshire <pderbysh@usa.net>
  1130. Subject: (fractint) Code improvement: call for ideas
  1131.  
  1132. Below is the isolated main iteration loop from my batchm.cc. Any suggesti=
  1133. ons
  1134. to improve it (chiefly, the periodicity-checking) are welcomed.
  1135.  
  1136. As is, it competes with Fractint and I think slightly outperforms it, whe=
  1137. n
  1138. compiled optimized for Pentium Pro class CPUs and into native 32-bit code=
  1139. =2E
  1140.  
  1141. (Its performance on low-end 486s and especially coprocessorless machines =
  1142. will
  1143. probably be underwhelming, however. It is targeted at Pentiums and above.=
  1144. )
  1145.  
  1146. iter is a short-hand typedef for unsigned long.
  1147.  
  1148. iter calculate_pixel (real x, real y) {
  1149.   real zx =3D 0;
  1150.   real zy =3D 0;
  1151.   real zx2 =3D 0;
  1152.   real zy2 =3D 0;
  1153.   real zzx =3D 0;
  1154.   real zzy =3D 0;
  1155.   real zzx2 =3D 0;
  1156.   real zzy2 =3D 0;
  1157.   real dst;
  1158.   iter i =3D 0;
  1159.   int mod16 =3D 0;
  1160.  
  1161.   while (zx2+zy2 <=3D bail_radius_squared && i < maxiter) {
  1162.     if (mod16 =3D=3D 16) {
  1163.       mod16 =3D 0;
  1164.       zzy =3D 2*zzx*zzy + y;
  1165.       zzx =3D zzx2 - zzy2 + x;
  1166.       zzx2 =3D zzx*zzx;
  1167.       zzy2 =3D zzy*zzy;
  1168.     }
  1169.     ++mod16;
  1170.     zy =3D 2*zx*zy + y;
  1171.     zx =3D zx2 - zy2 + x;
  1172.     zx2 =3D zx*zx;
  1173.     zy2 =3D zy*zy;
  1174.     ++i;
  1175.     dst =3D ldabs(zx - zzx) + ldabs(zy - zzy);
  1176.     if (dst < per_check_sens) i =3D maxiter;     // Periodicity checking =
  1177. caught
  1178. a cycle.
  1179.   }
  1180.   =
  1181.  
  1182.   return i;
  1183. }
  1184.  
  1185.  
  1186. ____________________________________________________________________
  1187. Get free e-mail and a permanent address at http://www.netaddress.com/?N=3D=
  1188. 1
  1189.  
  1190. - --------------------------------------------------------------
  1191. Thanks for using Fractint, The Fractals and Fractint Discussion List
  1192. Post Message:   fractint@lists.xmission.com
  1193. Get Commands:   majordomo@lists.xmission.com "help"
  1194. Administrator:  twegner@phoenix.net
  1195. Unsubscribe:    majordomo@lists.xmission.com "unsubscribe fractint"
  1196.  
  1197. ------------------------------
  1198.  
  1199. Date: Mon, 31 May 1999 22:40:53 -0600
  1200. From: Phil McRevis <legalize@xmission.com>
  1201. Subject: Re: (fractint) Fractal source code. 
  1202.  
  1203. In article <19990601041143.18014.qmail@www0t.netaddress.usa.net>,
  1204.     Paul Derbyshire <pderbysh@usa.net>  writes:
  1205.  
  1206. > Attached below are two source files, which are fairly short.
  1207.  
  1208. Neither of which have anything to do with fractint.  Paul, please make
  1209. sure your posts are relevant before you post...
  1210. - --
  1211. <http://www.xmission.com/~legalize/>    Legalize Adulthood!
  1212.     ``Ain't it funny that they all fire the pistol,     
  1213.       at the wrong end of the race?''--PDBT     
  1214. legalize@xmission.com    <http://www.eden.com/~thewho>
  1215.  
  1216. - --------------------------------------------------------------
  1217. Thanks for using Fractint, The Fractals and Fractint Discussion List
  1218. Post Message:   fractint@lists.xmission.com
  1219. Get Commands:   majordomo@lists.xmission.com "help"
  1220. Administrator:  twegner@phoenix.net
  1221. Unsubscribe:    majordomo@lists.xmission.com "unsubscribe fractint"
  1222.  
  1223. ------------------------------
  1224.  
  1225. Date: Mon, 31 May 1999 22:33:38 -0700
  1226. From: Mark Christenson <mchris@hooked.net>
  1227. Subject: (fractint) new images
  1228.  
  1229. It's not much to brag about, but after five months of infractivity 
  1230. I have finally added five new "gravibrot" images to my site, 
  1231. including my second layered image.  They can be found at
  1232.  
  1233. http://www.hooked.net/~mchris/merge.htm
  1234.  
  1235. More to come in the near future...
  1236.  
  1237.  
  1238. Aloha, Bud
  1239.  
  1240.  
  1241.  
  1242. - --------------------------------------------------------------
  1243. Thanks for using Fractint, The Fractals and Fractint Discussion List
  1244. Post Message:   fractint@lists.xmission.com
  1245. Get Commands:   majordomo@lists.xmission.com "help"
  1246. Administrator:  twegner@phoenix.net
  1247. Unsubscribe:    majordomo@lists.xmission.com "unsubscribe fractint"
  1248.  
  1249. ------------------------------
  1250.  
  1251. Date: Tue, 1 Jun 1999 01:40:28 EDT
  1252. From: Damascena@aol.com
  1253. Subject: Re: (fractint) new images
  1254.  
  1255. In a message dated 5/31/99 11:35:30 PM Mountain Daylight Time, 
  1256. mchris@hooked.net writes:
  1257.  
  1258. > five months of infractivity
  1259.  
  1260. What a perfect new word this is! Thank you for appropriate description of the 
  1261. cliched "dry spell." I like the images too <G>
  1262.  
  1263. Dama
  1264.  
  1265. - --------------------------------------------------------------
  1266. Thanks for using Fractint, The Fractals and Fractint Discussion List
  1267. Post Message:   fractint@lists.xmission.com
  1268. Get Commands:   majordomo@lists.xmission.com "help"
  1269. Administrator:  twegner@phoenix.net
  1270. Unsubscribe:    majordomo@lists.xmission.com "unsubscribe fractint"
  1271.  
  1272. ------------------------------
  1273.  
  1274. Date: 1 Jun 99 01:24:57 MDT
  1275. From: Paul Derbyshire <pderbysh@usa.net>
  1276. Subject: (fractint) Two fractal formats.
  1277.  
  1278. A simple, universal format for recording the details needed to color and
  1279. recolor an image, is as follows. All quantities are big-endian for consis=
  1280. tency
  1281. across platforms.
  1282.  
  1283.  
  1284.  
  1285. offset  qty.           type     description
  1286. 0x0000  1              ushort   width
  1287. 0x0002  1              ushort   height
  1288. 0x0004  1              ushort   # of distinct regions/basins. Basins will=
  1289.  be
  1290. numbered from 0 to this number minus one.
  1291. 0x0006  width*height   record
  1292.                        offset  qty.   type    description
  1293.                        0x0000  1      ushort  basin number
  1294.                        0x0002  1      double  pixel value (a double can b=
  1295. e
  1296. used to hold integers with 56 bits precision)
  1297.  
  1298.  
  1299. A rendering program will have to scan over all of the data to discover ho=
  1300. w
  1301. many basins there are and for each, what the
  1302. minimum and maximum values for the value are. This can be done while load=
  1303. ing
  1304. in the data. This is to keep the file format
  1305. simple. The file format can be modified by augmenting it with a compressi=
  1306. on
  1307. scheme such as LZSS.
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313. A slightly less simple format I have devised to record enough to allow th=
  1314. e
  1315. image to be resumed, zoomed, or the parameters
  1316. tweaked, or evolved, follows. It relies on the supposition of the develop=
  1317. ment
  1318. of an essential infrastructure.
  1319.  
  1320.  
  1321. The infrastructure would be a namespace system for the naming of formulas=
  1322. =2E I
  1323. propose the following: each person use some
  1324. easily-recognizable component of their name as their namespace name. They=
  1325.  name
  1326. their formulas in this scheme with that as a
  1327. prefix. I'd use PGD for mine, so PGD::Nova is the full name for the Nova
  1328. formula. Names will apply to Julibrot objects or to
  1329. stand-alone Julia types.
  1330.  
  1331. The classics, e.g. Mandelbrot, Julia, etc. would be named as they are.
  1332.  
  1333.  
  1334. Some classic (escape-time, 2 dimensional) fractals and their proposed nam=
  1335. es.
  1336.  
  1337. Fractal             Proposed name
  1338. z^2+c               Mandelbrot
  1339. z^n+c (n integer)   IntPMandelbrot
  1340. z^x+c (x real)      RealPMandelbrot
  1341. z^w+c (w complex)   CplxPMandelbrot                (corresponds to fracti=
  1342. nt
  1343. type=3Dmanzpower, julzpower)
  1344. z^z+z^w+c           ZZMandelbrot                   (type=3Dmanzzpwr, julz=
  1345. zpwr)
  1346. rx(1-x)             LambdaMandelbrot               (type=3Dlambda, mandel=
  1347. lambda)
  1348. c*f(z)              CfnMandelbrot                  (type=3Dlambdafn, mand=
  1349. elfn)
  1350. Newton z^n-1        NewtonUnity                    (type=3Dnewton, newtba=
  1351. sin)
  1352.                                                    (Unity as it is roots =
  1353. of
  1354. unity and not general Newton)
  1355.                                                    (Not a julibrot.)
  1356. Newton z^w-1 (w complex)      CplxNewton           (type=3Dcomplexnewton)=
  1357.  
  1358.                                                    (Not a julibrot.)
  1359. Newton z^3 + (c-1) z - c      NewtonCubic          (Generic cubical equat=
  1360. ion
  1361. Newton)
  1362.  
  1363.  
  1364. Formulas will have parameter names associated with their parameters. The
  1365. name's meaning is determined by the formula in
  1366. context. The commonest names will be:
  1367.  
  1368.  
  1369. name    type               description
  1370. seed    complex or hyper   Julia c values. May also be a vector quantity =
  1371. for
  1372. some formulas.
  1373. init    "       "  "       Mandel z_0 values. A critical point or value, =
  1374. e.g.
  1375. 0 for Mandelbrot, gives a true Mandelbrot
  1376.                            fractal. Any other value gives a perturbed
  1377. Mandelbrot.
  1378. exponent  integer, real, complex, hyper depending on formula
  1379.                            Exponent in Newton and z^n+c types. Analogous =
  1380. for
  1381. others.
  1382. function                   The function in CfnMandelbrot and friends.
  1383. function1, function2 ...     In multi-function relatives of lambdafn, lik=
  1384. e
  1385. Fractint's fn1*fn2+c.
  1386. For all of these, defaults are set by formula-specification.
  1387.  
  1388.  
  1389. Formulas will be assumed to have the attractors to check for specified in=
  1390.  the
  1391. formula.
  1392. A word on attractors. For Julia types, attractors are sought out by
  1393. "discovery".
  1394. For Mandelbrot types, attractors are specified in the formula, either as =
  1395. fixed
  1396. quantities (e.g. infinity for Mandelbrot)
  1397. or as some function of the parameters (as with Nova). Two special attract=
  1398. or
  1399. types will be infinity or find_fixed_point.
  1400. The latter will collect all points that tend to settle to one finite valu=
  1401. e.
  1402. Functions will be specifiable in some complex, yet to be devised format. =
  1403. A
  1404. fractal formula specification consists of:
  1405.  
  1406.  
  1407. string      1      Formula name with qualification, e.g. PGD::Nova.
  1408. string      1      Comments. See below about format for a comment string.=
  1409.  
  1410. record      any    Parameter specifications.
  1411.                    type    qty.    description
  1412.                    string  1       name of parameter
  1413.                    string  1       type-id, 'integer', 'real', 'complex'
  1414. allowed, 'complex' can be supplanted
  1415.                                    with hypercomplex with the hyper flag =
  1416. on.
  1417.                    uint    1       Number of dimensions for a vector valu=
  1418. e,
  1419. normally 1.
  1420.                    bool    1       Periodicity-checking applies to this
  1421. parameter? (Normally no except for the iteration
  1422.                                    variable)
  1423.                    The first parameter specified is the iteration variabl=
  1424. e
  1425. (possibly a vector). Its name will often be 'init'
  1426.                    to match the above convention for the classic types.
  1427. delimiter
  1428. n-place-function  1   Specifies the new value of the first parameter in t=
  1429. erms
  1430. of all of the parameter values (incl. previous
  1431.                       value of first parameter). May be a vector-valued
  1432. function to match the first parameter's nature.
  1433. bool        1      Suppress Julibrot behavior and act pure Julia. (e.g.
  1434. NewtonUnity.)
  1435.  
  1436.  
  1437. This will usually specify a Julibrot object. A Julia set is taken by fixi=
  1438. ng
  1439. parameters in the image except to pixel-vary
  1440. init. A Mandelbrot set (or slice thereof) is taken by pixel-varying a sli=
  1441. ce of
  1442. the parameter space except for the fixing
  1443. of init at a critical point or critical value. A perturbed Mandelbrot set=
  1444.  is
  1445. taken by doing the same except to fix init at a
  1446. point that isn't a critical point or critical value. An oblique slice is =
  1447. taken
  1448. by using some other more general manner of
  1449. slicing.
  1450.  
  1451. If there is one init parameter and one other, seed parameter, you have a =
  1452. 4-D
  1453. Julibrot with planar M-sets and planar
  1454. Julia sets.
  1455.  
  1456.  
  1457. To specify the classic M-set Julibrot:
  1458.  
  1459. string    Mandelbrot
  1460. string    The original classic!
  1461. record    string    init
  1462.           string    complex
  1463.           uint      1
  1464.           bool      true
  1465. record    string    seed
  1466.           string    complex
  1467.           uint      1
  1468.           bool      false
  1469. delimiter
  1470. n-place-function      (init |-> init*init+seed, specified somehow)
  1471. bool      false
  1472.  
  1473.  
  1474. A convolution is a collection of n n-place functions, where n is the numb=
  1475. er of
  1476. parameter-space dimensions, often 4.
  1477. The dimension of a convolution should match the dimension of the fractal =
  1478. to
  1479. which it is applied, in the larger sense.
  1480.  
  1481. An escape shape is a function that returns a bool from a vector, dependin=
  1482. g on
  1483. the vector escaping a certain shape. The shape
  1484. should have a radius of around 1, it will be scaled automatically when us=
  1485. ed.
  1486.  
  1487. A plane through the origin in n dimensions is specified by n real
  1488. coefficients. These will be termed c_1, ..., c_n, and
  1489. the real basis components for the parameter space x_1, ..., z_n. Then the=
  1490.  
  1491. plane specified is that satisfying:
  1492. c_1*x_1 + c_2*x_2 + ... + c_n*x_n =3D 0.
  1493.  
  1494. Format: a ushort, the number of dimensions, then n reals.
  1495.  
  1496.  
  1497. How to specify an arbitrary n-valued function.
  1498.  
  1499.  
  1500. record    any    Parameters
  1501.                  string     1    name
  1502.                  string     1    type  (bool, integer, real, complex,
  1503. function)
  1504. delimiter
  1505. record    any    Temporaries
  1506.                  string     1    name
  1507.                  string     1    type  (bool, integer, real, complex)
  1508. delimiter
  1509. record    any    calculation steps
  1510.                  string     1    operation to perform: add, multiply, squ=
  1511. are,
  1512. recip, <=3D, >=3D, invoke parametrized function,
  1513.                                  etc. Two special ops: 1. Set a label. 2.=
  1514.  
  1515. Branch to a label if param 1 is true.
  1516.                  string     1    dest-param [If operation to perform is a=
  1517. n
  1518. assignment and not a conditional]
  1519.                  bool       1    source-param-1 is a parameter.
  1520.                  string     1    source-param-1  [If source-param-1 is a
  1521. parameter]
  1522.                  some type  1    source-param-1  [If not, i.e. source-par=
  1523. am-2
  1524. is a constant]
  1525.                  string     1    source-param-2  [Only if operation is bi=
  1526. nary
  1527. and not unary and it's a parameter here.]
  1528.                  some type  1    source-param-1  [Only if operation is bi=
  1529. nary
  1530. and not unary and it's a constant here.]
  1531.                  string     1    param-name of function to invoke [only i=
  1532. f
  1533. that is the operation to perform]
  1534.                  string     1    label-name if we are declaring a label o=
  1535. r
  1536. conditionally branching to one.                 =
  1537.  
  1538. delimiter
  1539. string    1      name of temporary to return.
  1540. ulong     1      Maximum number of steps before aborting. Ensures the fun=
  1541. ction
  1542. cannot hang.
  1543. return type  1   Value to return on abort.
  1544.  
  1545.  
  1546. When these are compiled:
  1547. * Type mismatches between number and function values will cause an error.=
  1548.  
  1549. * Conversions will be implicitly inserted among the non-function types.
  1550.   Anything to bool: 0 =3D false, anything else =3D true.
  1551.   Bool to anything: false =3D 0, true =3D 1.
  1552.   Integer to real to complex: As expected, value unchanged.
  1553.   Complex to real: Chop all but real component.
  1554.   Real to integer: Round to nearest, round 0.5 up.
  1555. * Integer operations and such may be optimized, e.g. z^3 should be as fas=
  1556. t as
  1557. possible if the parameter 3 is an integer type,
  1558.   and in particular will then be faster than if the 3 was in a complex
  1559. parameter type.
  1560. * Operations using constants should be faster by taking advantage of the =
  1561. exact
  1562. value of the constant if it is a small integer.
  1563.   I.e. z^2 with the 2 constant can be translated into the fast cplx sqyar=
  1564. ing
  1565. procedure.
  1566. * Function parameters must be either unary or binary functions. Ident, ze=
  1567. ro,
  1568. one, recip, sqr, add, multiply, etc.
  1569. * The defined function's return type is that of the parameter named near =
  1570. the
  1571. end as the return. It is returned at successful
  1572.   exit of the loop.
  1573. * The parameter of a branch is implicitly converted to a boool of course.=
  1574.  
  1575. * Some fast operations for integers: increment, decrement, ...
  1576. * Manner of compilation is application-dependent. Compilation to a linked=
  1577.  list
  1578. of function pointers or to byte codes is
  1579.   platform-independent. JIT compilation to native machine instructions is=
  1580.  also
  1581. an option for ultrafast operation on specific
  1582.   targets.
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. With that taken care of, some fractal parameters that are universal regar=
  1589. dless
  1590. of formula:
  1591.  
  1592. center       complex or hyper     Center of image   Default: Depends on
  1593. formula.
  1594. mag          real                 Magnification: 1 will mean the image ha=
  1595. s a
  1596. longer dimension of 1 in the fractal space.
  1597.                                   10 will mean the larger dimension is 0.=
  1598. 1,
  1599. and so forth by reciprocals.
  1600.                                   Default: depends on formula.
  1601. rotation     real                 In degrees: image rotation (clockwise).=
  1602.  
  1603. Default: 0.
  1604. skew         real                 Skew. Default: 0.
  1605. maxiter      ulong                Maximum number of iterations to try.
  1606. Default: 2048.
  1607. hyper-flag   bool                 Hypercomplex or not. Affects the nature=
  1608.  of
  1609. center. Default: false.
  1610. quat-flag    bool                 Quaternion flag. Mutually exclusive wit=
  1611. h
  1612. hyper-flag and with formulas using trig/exp on a
  1613.                                   complex parameter.
  1614.                                   Either of these doubles all parameter s=
  1615. pace
  1616. dimensions.
  1617.  
  1618. outer_radius real                 Radius (not squared) for checking escap=
  1619. e to
  1620. infinity if there is an attractor there.
  1621.                                   Default: depends on formula.
  1622. inner_radius real                 Target radius around all finite attract=
  1623. ors.
  1624.                                   Default: depends on formula.
  1625. outer_shape  string               Formula name for an escape-shape formul=
  1626. a.
  1627. Builtins such as "circle", "square", "astroid",
  1628.                                   "ribbon", ...
  1629.                                   Default: circle.
  1630. inner_shape  string               Same. Determines the shapes of target a=
  1631. reas
  1632. around finite attractors or fixed-point-trap.
  1633.                                   Default: circle.
  1634. outer_shape_parms  various        Depends on shape. Might be aspect ratio=
  1635.  of
  1636. an ellipse, etc.
  1637.                                   Defaults: depend on shapes.
  1638. inner_shape_parms  various        Depends on shape. Might be aspect ratio=
  1639.  of
  1640. an ellipse, etc.
  1641.                                   Defaults: depend on shapes.
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647. Whatever varies by pixel, if the parameter in question is assigned-to in =
  1648. the
  1649. parameter list, this assignment is ignored
  1650. (the pixel overrides) and a warning generated.
  1651.  
  1652.  
  1653. Now, the fractal description would be as follows. Here, as variable-lengt=
  1654. h
  1655. strings are used there will be no offsets
  1656. specified. Type 'string' means ASCII, null-terminated. A formula name or
  1657. parameter name is as above. =
  1658.  
  1659.  
  1660.  
  1661. parameter-block-marker
  1662. type     qty.     description
  1663. string   1        Description and comments, including linefeeds for line
  1664. breaks, null terminated as always. Default: A null
  1665.                   by itself (empty string) or perhaps computer-generated,=
  1666.  say,
  1667. date and time written and CPU detected.
  1668. string   1        formula name     Default: Mandelbrot.
  1669. string   1        convolution of coordinates -- a named convolution formu=
  1670. la  =
  1671.  
  1672. Default: identity.
  1673. string   any      paramater-name =3D value. Values may be in high precisi=
  1674. on,
  1675. forcing supporting software to use
  1676.                   high precision if any value is (or if the mag is high
  1677. enough) and non-supporting software to complain or
  1678.                   generate fuzzy or imprecise images. Default: defaults.
  1679.                   Sets parameters for formula, convolution, escape traps,=
  1680.  and
  1681. so forth.
  1682. delimiter         =
  1683.  
  1684.  
  1685. The next stuff is in three optional, mutually-exclusive groups.
  1686.  
  1687. full-julibrot-flag                Makes image an arbitrary Julibrot slice=
  1688. =2E
  1689. plane        real coefficient list  Default: plane is some interesting
  1690. opblique plane in parameter space.
  1691.                                   Determines equation of plane through or=
  1692. igin.
  1693.                                   Image slices hypercomplex and/or julibr=
  1694. ot
  1695. slices or many-dimensional
  1696.                                   Julia sets. Image center is in full
  1697. parameter-space and slice plane is through this
  1698.                                   parallel to plane whose equation is giv=
  1699. en.
  1700. OR
  1701.  
  1702. julia-flag                        Makes image a Julia set.
  1703. plane-flag                        True means a plane follows.
  1704. plane                             Slice for vector space of "init". Plane=
  1705.  
  1706. through origin as usual. Slice through parameter
  1707.                                   space is parallel and through center.
  1708. Default is flat in first two real components in
  1709.                                   vector.
  1710.  
  1711.  
  1712. OR
  1713.  
  1714. mandelbrot-flag                   Makes image an M-set.
  1715. string      1                     Parameter-name: names parameter that va=
  1716. ries
  1717. by pixel and determines image center.
  1718.                                   Center is a vector of that parameter.
  1719. plane-flag                        True means a plane follows.
  1720. plane                             Slice for parameter space. Plane throug=
  1721. h
  1722. origin as usual. Slice through parameter space is
  1723.                                   parallel and through center. Default is=
  1724.  flat
  1725. in first two real components in vector.
  1726.  
  1727.  
  1728. [Now the fractal is specified, independent of coloring schemes or display=
  1729.  
  1730. resolution. This can be used as a compact parameter file.]
  1731.  
  1732.  
  1733. algorithm-choice-block-marker
  1734. string   1       Algorithm type: 1pass, ..., npass (for reasonably large =
  1735. n),
  1736. tesseral, guessingn (n is number of passes, 1
  1737.                  is same as using 1pass), boundary, synchronous, diffusio=
  1738. n.
  1739. Default: guessing5.
  1740. real     1       Tolerance for determining how similar pixels are for pur=
  1741. poses
  1742. of tesseral and b-trace and s-guess. 0 means
  1743.                  must be identical. Default: 0.
  1744. periodicity  real      Periodicity checking sensitivity. Orbits that repe=
  1745. at to
  1746. within periodicity/mag are a cycle
  1747.                        detection. The factor of mag adjust the sensitivit=
  1748. y
  1749. automatically for deeper magnification.
  1750.                        Default: 1x10^-7, or is there a less conservative =
  1751. value
  1752. that gives good results? Better yet, depends
  1753.                        on formula.
  1754.  
  1755. [Now details of algorithm are specified.]
  1756.  
  1757.  
  1758. image-dimension-block-marker
  1759. ulong    1       width in pixels     Default: 1024
  1760. ulong    1       height in pixels    Default: 768
  1761.  
  1762. [Image is imagined to be a square of side 1/mag centered on center, then
  1763. truncated from top and bottom or from left and right
  1764.  symmetrically to have the specified proportions.]
  1765. [Specifies everything needed to batch-generate the data now.]
  1766.  
  1767.  
  1768. basin-info-block-marker
  1769. ushort   1                   # of basins
  1770. real     2*number of basins  min and max for each basin
  1771. complex or whatever    number of basins      Attractors, if there is one =
  1772. at
  1773. infinity it is attractor zero and the
  1774.                                              coordinates are ignored, if
  1775. fixed-point-trap is an attractor it is number 1 and
  1776.                                              again the coordinates are
  1777. ignored.
  1778.  
  1779. [Specifies "discovered" properties of the fractal.]
  1780.  
  1781. pixel-data-block-marker
  1782. record   width*height    Generated image data
  1783.                          type      qty.    description
  1784.                          ushort    1       Basin number. Remember
  1785. maxiter/periodicity is the last and infinity, if present,
  1786.                                            the zeroth.
  1787.                          ulong     1       Iterations. (Less than maxiter=
  1788.  for
  1789. periodicity-caught pixels!)
  1790.                          ulong     1       Period. (In case periodicity
  1791. checking caught the pixel. 0 if not found periodic.)
  1792.                          real      1       Distance from origin or recip =
  1793. of
  1794. distance from finite attractor when caught in
  1795.                                            a trap. (Recip of distance fro=
  1796. m
  1797. last point for fixed-point-trapping.)
  1798.                          real      1       Angle to attractor (to origin =
  1799. for
  1800. infinity, to previous point for
  1801.                                            fixed-point-trapping).
  1802.                          real      1       Other data, special purpose, f=
  1803. ixed
  1804. by formula.
  1805.                          real      2       Coordinates of terminal value.=
  1806.  
  1807.  
  1808. ushort   1               Days
  1809. byte     1               Hours
  1810. byte     1               Minutes
  1811. byte     1               Seconds
  1812. real     1               Fraction of a second    Calculation time
  1813. ulong    1               Pixels per second averaged
  1814.  
  1815.  
  1816. [Specifies whole fractal without a coloring.]
  1817.  
  1818. coloring-data-block-marker
  1819. record   any      Color-maps, applied sequentially to attractor basins.
  1820.                   type    qty.        description
  1821.                   record  1 or more   Color-map.
  1822.                                       type    qty.     description
  1823.                                       real    1        Between 0 and 1
  1824. inclusive, specifies a value relative to the min-max
  1825.                                                        range of the value=
  1826.  in
  1827. the basin.
  1828.                                       byte    3        red, then green, t=
  1829. hen
  1830. blue, between 0 and 255 inclusive.
  1831.                                       byte    1        0 =3D linear to ne=
  1832. xt
  1833. point 1 =3D quadratic 2 =3D cubic interpolation.
  1834.                   Default: Something serviceable. Greyscale perhaps.
  1835. 7-place-function    any      Functions applied (one per basin) to transfo=
  1836. rm
  1837. the raw data into a value.
  1838.                   Default: iterations for all basins, except
  1839. maxiter/periodicity, where it is constant equal to 0.
  1840. 1-place-function    any      Functions applied (one per basin) to transfo=
  1841. rm
  1842. the output one step further, e.g. for a logmap.
  1843.                              The min and max of the final value
  1844.                              Default: the identity, i.e. the output equal=
  1845. s the
  1846. input.
  1847.  
  1848. [Here, the color map indexes between 0 and 1 must be nondecreasing. Succe=
  1849. ssive
  1850. identical values are allowed to control
  1851.  splines which use neighbor points for interpolation. Quadratic uses prev=
  1852. ious,
  1853. current, and next to determine current to next, and
  1854.  cubic uses previous and next-after-next for control points.]
  1855. [The attracting basins are numbered from 0 up as follows: any
  1856. formula-specified attractors in given order, then for Julias any
  1857.  discovered attractors in order of encountering their basins left to righ=
  1858. t,
  1859. top to bottom. Lastly the color for max-iter.
  1860.  Minima and maxima are determined from the raw data. So the scheme is
  1861. well-defined.]
  1862. [The foregoing specifies a fractal without regard to resolution or genera=
  1863. ting
  1864. algorithm.]
  1865.  
  1866.  
  1867.  
  1868.  
  1869. This should be a reasonable first draft of a universal fractal data forma=
  1870. t,
  1871. which can have various levels of detail.
  1872. One should augment it by using LZSS compression at least when storing a w=
  1873. hole
  1874. fractal's data. Each of the sections (fractal params,
  1875. algorithm specification, color specification, raw data, etc.) should be
  1876. optional and delimited. An omitted section (except the raw
  1877. data and the "discovered" basin data) is regarded as all values their def=
  1878. aults
  1879. (as specified by the formula if necessary --
  1880. maybe the formula default, Mandelbrot). An omitted parameter is assumed
  1881. default. A named parameter not a standard name or
  1882. specified in a formula (escape radius, convolution, fractal iteration etc=
  1883. =2E)
  1884. causes a warning message.
  1885. As for computed data, if not specified it is computed.
  1886.  
  1887. The information stored per pixel is enough to use the saved data to quick=
  1888. ly
  1889. render using any of the following methods:
  1890.        Solid color in a basin
  1891.        Iterations
  1892.        Atan or decomp (using the angle value)
  1893.        Potential      (using iterations and the distance; should work aro=
  1894. und
  1895. finite attractors using the provided recip-of-distance!)
  1896.        Real, imag, summ, etc.   (using the coordinates z_final)
  1897.        Period         (using period value)
  1898.        Distance estimator (using the 'special' field and a special formul=
  1899. a to
  1900. put the 'distance' information in that field)
  1901.        And so forth...
  1902.        =
  1903.  
  1904.        =
  1905.  
  1906.  
  1907. ____________________________________________________________________
  1908. Get free e-mail and a permanent address at http://www.netaddress.com/?N=3D=
  1909. 1
  1910.  
  1911. - --------------------------------------------------------------
  1912. Thanks for using Fractint, The Fractals and Fractint Discussion List
  1913. Post Message:   fractint@lists.xmission.com
  1914. Get Commands:   majordomo@lists.xmission.com "help"
  1915. Administrator:  twegner@phoenix.net
  1916. Unsubscribe:    majordomo@lists.xmission.com "unsubscribe fractint"
  1917.  
  1918. ------------------------------
  1919.  
  1920. End of fractint-digest V1 #395
  1921. ******************************
  1922.  
  1923.