Giter VIP home page Giter VIP logo

julia's Introduction

License: LGPL v3 picocli Donate

Julia: The Fractal Generator

Julia is a fractal generator program completely written in Java. It started as a college work around 2010. Despite its age, this project is still fully functional. Here is a screenshot of Julia running on Windows 10:

Julia 1.1 running on Windows 10

Please note that this project focuses only on two-dimensional, escape-time fractals like the Mandelbrot set and the Julia set. A clear and concise definition of such a fractal is that given by Tom Van Cutsem:

Such fractals are computed by repeatedly applying a transformation to a given point in the plane. The obtained series of transformed points is called the orbit of the initial point. An orbit diverges when its points grow further apart without bounds. A fractal can then be defined as the set of points whose orbit does not diverge.

Main features

Pluggable architecture

Any image created with Julia results from the combination of 3 pluggable elements:

  • Number factory. Unlike other programs, Julia does not endorse/embed any specific library for doing arbitrary precision computations. Instead, it is possible to have one or more number factories, each representing a link between Julia and a particular package. This allows users not only to switch from fixed to arbitrary precision arithmetic as they start deep zooming; users will also have the choice to switch from (say) Apfloat to JScience, or any other library, even native ones, provided the specific number factory is available.

  • Formula. Any recurrence relation that can generate fractals in the complex plane. Here are some examples:

    • equation
    • equation
    • equation

    Formulas use resources provided by the number factory to carry out computations. Each is capable to generate one Mandelbrot set and infinitely many Julia sets.

  • Representation. Any possible rendering method/algorithm. To better explain what means using a certain representation instead of another, look at these examples:

    Tangent circles Escape time Mu-Ency Ring segments Stalks

    These images were generated by Julia applying 5 different representations to the same formula. While other two partners act more like “service providers”, representation is the active element that actually carries out the entire rendering process.

Multithreaded rendering

The rendering process can be splitted into several concurrent flows in order to take advantage of modern multiprocessor architectures.

JIM I/O format

Beside common formats like JPEG, PNG etc. (only available as outputs), Julia provides its own file format called JIM (Julia IMage). JIM files can be further edited in Julia; incomplete renderings are saved with the ability to be resumed after opening.

Running Julia

Being written in Java, Julia requires JRE/JDK 1.8+ to be installed in your system.

On Windows

Windows users should just download and run julia.exe (latest release here). SmartScreen may complain about the signature so youl'll have to click More info and then Run anyway. If no JRE 1.8+ installation is found, a popup will give instructions to download and install the latest version of Java.

Please note that if you want to use the CLI as well as the GUI you should download juliac.exe instead.

On other OSes

After installing Java, you should be able to run Julia simply double clicking on julia.jar. Alternatively, you can run Julia from the command line by typing:

java -jar julia.jar

Also note that the command line is not only accessible through terminal emulators/command prompt. Most OSes/desktops provide Run dialogs that hide once you issued a command.

Missing plugins error

First time Julia is started you will get an error about missing plugins. That's because Julia doesn't come equipped with any of the pluggable elements discussed above. You can install DPC4J that provides a minimal set of plugins to start exploring fractals.

Command Line Interface (CLI)

Below you'll find some examples of using the Julia CLI to generate images. Examples will make use of juliac.exe just for brevity: it's intended that they apply also when using java -jar julia.jar to run the program.

Simplest case

Mandelbrot set of quadratic formula (full view) using the escape time algorithm (all parameters set to default), 800x600 pixels, PNG format:

juliac.exe generate -n Double -f Quadratic -r EscapeTime -W 800 -H 600 -o mandelbrot.png

At a minimum, we need to specify the number factory (-n), the formula (-f) and the representation (-r) to be used.

To save in a different format, just use a different extension in the output file name.

Julia set generation

Full view of Julia set at (0.285, 0.01), JPEG format, everything else as above:

juliac.exe generate -n Double -f Quadratic -r EscapeTime -W 800 -H 600 -o julia.jpg c=0.285,0.01

A "default" Julia set point which depends on the formula being used can be set passing c=default.

Zooming

Back to Mandelbrot set. This is a detail of what is known as Seahorse Valley:

juliac.exe generate -n Double -f Quadratic -r EscapeTime -W 800 -H 600 -o mandelbrot-seahorse.png rect=−0.74303,[email protected] r.maxIterations=2000

A partial view is set with rect=Recenter,Imcenter@Width (without whitespaces).

Note that we are also raising the maximum number of iterations to avoid loss of accuracy. This is accomplished by r.maxIterations=2000 which sets the maxIterations parameter of the selected representation to a higher value (the default for EscapeTime is 500).

Julia CLI also supports partial views specified as rect=Re0,Im0,Re1,Im1. When using this format, Julia will force 1:1 pixel ratio enlarging rect as much as needed to fit the aspect ratio of the output image. This behaviour can be prevented passing --no-force-equal-scales.

Setting color and gradient parameters

Following example sets the untrappedOutsidePoint parameter of TangentCircles to a transparent color (the format is R,G,B,A), the untrappedInsidePoint parameter to an opaque color (alpha is omitted) and the trappedPoint4 parameter to a gradient starting from color (0, 255, 108) going to (255, 64, 44) and stopping at (0, 0, 96):

juliac.exe generate -n Double -f Quadratic -r TangentCircles -W 800 -H 600 -o mandelbrot-tc.png r.untrappedOutsidePoint=25,150,82,50 r.untrappedInsidePoint=80,140,200 r.trappedPoint4=0,255,108@0^255,64,[email protected]^0,0,96@1

Using parameter hints

Here we are telling Julia to set the gradient parameter of EscapeTime to its third hint (note that hints are enumerated starting from zero):

juliac.exe generate -n Double -f Quadratic -r EscapeTime -W 800 -H 600 -o mandelbrot.png r.hint.gradient=2

Using hint groups

Hint groups can be recalled similarly as hints but using * instead of a parameter name:

juliac.exe generate -n Double -f Carlson -r TangentCircles -W 800 -H 600 -o mandelbrot-tc-fig5.png r.hint.*=fig5

Hint groups can also be used to set individual parameters. E.g. passing r.hint.rc=fig5 will set the single parameter rc to its value inside group fig5 (other parameters in the group will be unaffected).

Setting number factory and formula parameters

You can use the prefixes n and f respectively:

juliac.exe generate -n BigDecimal -f Multibrot -r EscapeTime -W 800 -H 600 -o multibrot.png n.precision=32 f.bailout=100

Here precision is a parameter of the BigDecimal number factory while bailout pertains to the Multibrot formula.

Setting equivalent parameters across different plugins

It may happen that formula and representation (e.g.) have equivalent parameters with the exact same name and meaning (e.g.: bailout). In this case we might want to set these parameters consistently:

juliac.exe generate -n Double -f Mandelbrot -r MuEncy -W 800 -H 600 -o muency.png *.bailout=100

JIM output

To save in JIM format, just append the .jim extension to the output file name.

Currently it is not possible to save a partial rendering when using the CLI (it is only possible when using the GUI). I will try to address this limitation in the next releases.

JIM input

JIM images can be returned to the CLI using the -i option. This way you can just convert them to PNG or JPEG:

juliac.exe generate -i muency.jim -o muency.png

Or you can tweak some parameters and then save to a traditional format (or stick with JIM):

juliac.exe generate -i muency.jim -o muency-alt.png r.angleWeight=4

You can tweak everything. You can even change a plugin or switch between Mandelbrot set/Julia set but remember that every modification that is different from a change in the value of a previewable parameter will require Julia to repeat the calculation from scratch.

Building Julia

You need JDK 1.8+ and Maven installed in your system:

git clone https://github.com/mbilotta/julia.git
cd julia
mvn clean package

Building executable wrappers for Windows

Run the following:

mvn -P rel clean package

Credits

Thanks to Robert Munafo for providing valuable informations on fractal rendering algorithms througout its Mu-Ency site.

Icons

Most of the icons were taken/derived from the Momenticons matte set by Momentum Design Lab, licensed under Creative Commons Attribution 3.0 unported (CC BY 3.0).

Some other icons were taken from the Farm-fresh set by FatCow Web Hosting, licensed under Creative Commons Attribution 3.0 United States (CC BY 3.0 US).

Supporting this project

paypal

Licensing information

Julia is provided under the terms of the GNU Lesser General Public License (LGPL), ver. 3. You can read the license terms clicking the About Julia button in the dialog you see the first time it runs or you can open Help → About Julia in the main UI.

This program is distributed in the hope that will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILIY or FITNESS FOR A PARTICULAR PURPOSE. For more details, refer to the specific license.

julia's People

Contributors

dependabot[bot] avatar mbilotta avatar

Stargazers

 avatar  avatar

Watchers

 avatar

julia's Issues

Computation throttling

I'd like to have a way for users to throttle fractal image computation. Using this functionality users will be able to limit CPU utilization to keep resources for other programs running along with Julia.

Better handling of *.jim files whitout intermediate image when opened from File/Open...

Currently, an error message is displayed with the UI left in some dirty state.

A better behaviour would be:

  1. If there is only one control window, simply load the JIM data into that window and move that window to front.
  2. If there are more than one control windows (even if they're all hidden), inform the user he/she must open this file from a control window and do nothing.
  3. Simply open a new control window showing image data. That new window will have the same name as the file.

Oversampling

This is a feature I'd really like and I think it should be possible to have it implemented without the need of support from representation plugins. Basically there should be a way to tell Julia to render 2, 3 or 4 times the size of the requested image and then scale it down averaging the colors inside blocks of 2x2, 3x3, 4x4 respectively. Of course this approach requires a huge amount of memory but could be applied to any representation transparently.

Headless operation

Sooner or later Swing will be deprecated in favor of JavaFX (or somewhat else) but I don't plan to rewrite the UI in the near future. That stated, a simple way to make Julia future-proof is to improve its CLI to provide users a complete headless experience.

Invert the semantic of Pin/Unpin button

Instead of Pin/Unpin, this button should be named something like "Disconnect from/Connect to main UI". The button should look pressed when the control window acts like connected (aka "unpinned"). This is the opposite of the current behaviour which is quite unintuitive. Of course, icons also should change.

Provide some command line utility to create JUP packages

Ok, I started to work on this using Commons CLI but that led to a dead-end. The biggest limit I've found is the fact there is no way to parse a command line entirely. If a command line contains an unrecognized option, you can choose if the parser should throw an exception or not, but parsing must always stop at the point that option is encountered. This behavior really doesn't help when you want your CLI to bifurcate basing on the presence of one option from a set of mutually exclusive ones. Julia CLI should work like this. At the highest level, user may choose between two options:

  • Run Julia eventually passing a different profile directory than the default one (~/.juliafg).
  • Create a JUP archive.

While looking for alternatives, I've found picocli that looks promising. This library seems to be much more powerful and elegant and also fits in a single .java file that I can directly embed in my code (as suggested by the author).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.