Skip to content
tamchow edited this page Jul 3, 2016 · 1 revision
Java CLI Fractal Generator

For proper project documentation, refer here.

A Java fractal generator (currently UI-silent, with configuration through a file), that implements display of custom functions, with constant declaration processing, in Mandelbrot, Newton,Secant,Nova (both Mandelbrot and Julia types) and Julia modes, and an experimental IFS/LS render system.

There are also Buddhabrot techniques ( naive algorithm ) for each of the above.
<br/>
There are 36 different colouring schemes, 15 have linear interpolation, 17 have Catmull-Rom Spline interpolation and
2 which directly render in grayscale for emphasis on inner regions. The final is distance estimation based grayscale
or palette coloring, which is slow and has the same limitations as Newton/Nova mode as it uses the same mathematics
(symbolic differentiation) backend.
<br/>
There's also an ASCII art output type, for, you know,
<code>ComplexFractalGenerator</code>
objects.
<br/>
Degrees of functions are auto-calculated for use in calculating the renormalized iteration count.
The automatic degree calculation system might have a few issues with grouped operations, especially if considering
division or multiplication in the equation.
<strike>
    This calculation can be manually overriden after initializing the fractal generator with
    <code>setDegree(double)</code>
    of the <code>ComplexFractalGenerator</code> object in the<code>Test</code>class. This could be made more
    accessible once a GUI is made.
    Specifying a degree value in the configuration file will also override the calculation of the degree, which can
    be a complex value.
</strike>
<br/>
Indexing of colours can be linear or logarithmic (which provides better results than sqrt scaling).
<br/>
Colors can be interpolated directly or via their R, G and B components, or via their palette indices (in spline
interpolation only).
<br/>
The spline-interpolant methods are the standard ones of Triangle Area Inequality, Curvature Average and Stripe
Average, as well as Histogram coloring (by extension Rank-Order mapping) and Color Distance Estimation,Orbit and
Line Traps and Gaussian Distance and Epsilon Cross, by default.
<br/>
The linear interpolant methods have the 3 Newton fractal coloring modes, and the division and multiplication direct
and normalized coloring modes, and linear versions of the spline-interpolant methods,excepting distance estimation
and traps.
<br/>
(Actually, they have it too, but it isn't a separate coloring mode,
toggle it with the modifier flag in the color configuration.
Spline interpolation is the default (flag is false).)
<br/>
<strike>Resolution of the fractal is preferred to be in 2m+1x2n+1 format for proper symmetry.</strike>
Any resolution will work as long as it doesn't cause OOM (On my PC, it gives OOM errors at about 8K)

Supported modes: Julia, Mandelbrot, Newton, Nova (both mandelbrot and Julia variants) and Secant, with Buddhabrot technique variations available for each.
The Newton/Nova fractal generator can handle simple polynomials with coefficients and exponents which are expressions in themselves, but it uses a different input format:
coefficient: (optional)variable (optional): (optional)exponent (optional),+ or - or * or /,coefficient:variable:exponent...

Example: 1:z:3,-,c:z:2,+,1 (equivalent to (z3)-(c*z2)+1)
It can also handle simple transcendental functions like log,exp,sin,sinh,cos,cosh.
This is the input format:
polynomial; (optional)function (optional);polynomial (optional);exponent;constant (optional)|+ or - or * or /|polynomial;function;polynomial;exponent;constant...
The 1st polynomial is the coefficient,the 2nd is the function argument.
Only the coefficient is required, but if the function is supplied then everything except the constant is required.
Example: 1;sin;1:z:2;f (equivalent to sin(z2)+f)
Standard expressions can have embedded conditionals of the form:
[ conditional ? result if conditional is true : result if conditional is false ]
This is similar to the Java ternary operator syntax, and all Java primitive comparisons are supported, except:

  1. The equality comparison is "=" instead of the Java "=="
  2. No boolean logic operations are available.
    To get around this, use:
    1. Nested conditionals for Boolean AND
    2. Consecutive conditionals for Boolean OR
    3. I don't know of a workaround for Boolean XOR, but who uses it anyway?

Colorings currently available are based on:
  1. Simple mode: iteration count is used as a direct index into the palette (interpolation available as SIMPLE_SMOOTH)
  2. Division of 0xffffffff by integer or fractional iteration count (interpolation available)
  3. Bit-shift mode with results similar to division by integer or fractional iteration count (interpolation available)
  4. High contrast Grayscale mode
  5. Low Contrast Grayscale Mode
  6. Full custom or base-step, or linear- or spline-interpolated control points gradient palette mode by fractional iteration count (interpolation available)
  7. Randomized palette mode by fractional iteration count (interpolation available)
  8. Newton Mode - maximum modulus (linear or spline) or root reached
  9. Domain coloring- standard or faux on basis of lightness parameter
  10. Histogram Coloring (interpolation available)
  11. Rank-order color maping (interpolation available)

The final is distance estimation based grayscale or palette coloring, which is slow and has the same limitations as Newton mode as it uses the same mathematics (symbolic differentiation) backend.
Support for IFS Affine Transform or function-based fractals or L-System ones such as the fern are in place.

Multithreading -- Available for complex number fractals and IFS fractals (not including L-System ones and animations)!

Use is encouraged, but memory requirements are a bit high.

More standard coloring methods are there, such as:

  1. Triangle Area Inequality
  2. Curvature Average
  3. Stripe Average
  4. Orbit and line traps (min.,max.,average)
  5. Gaussian Distance
  6. Epsilon Cross Distance
Also, these modes support Catmull-Rom Spline and linear interpolation.
These coloring methods will affect only the palette-based methods of colouring.

NOTES: The fractal generator is extensible and multithreaded, and multithreading works well, albeit being quite resource intensive, requiring about a 20x increase in memory requirements for about a 10x speedup during generation (12 threads). Also, there might be OOM errors in very intensive cases (20+ threads at 640x480).

Also, there is full support for zoom, but renders after zoom are slow for higher base precision values. There is also support for panning, but pure complex function fractals are the only ones which support on-demand panning, others require regenerating the fractal. As a thumb rule, for quadrupling total resolution, double base precision for best results.

OUTPUT: Default debug and progress is output to console, and the final image(s) are saved serially as Fractal_no..png (except for animated IFS and/or L-System fractals, which are output frame-by-frame into a folder) in the output directory specified in the CMD arguments to the program.
For test launches, the result is saved as Fractal.png in the current working directory.

There is also an included image viewer, which can also generate and display standard complex number fractals. Enable it with the -v command-line switch.
There is support for elementary image transitions from top, bottom, left and right in the viewer, again configurable.
However, saving of the fractal image and zooming in the viewer are both supported but untested. All input to the application is currently handled by:

  1. Through a configuration file, whose path has to be specified as an argument while running the application
  2. Or use the pre-configured test shell script
Image and Fractal configuration files are a stickler for format, but do support inline comments with "#", as in .ini files.

I do not have much time for putting in documenting comments. I'll put them in and update files as and when possible.

Clone this wiki locally