2012-05-15

Iterated Function Systems

I have been working on a little project in my spare time to draw pretty pictures of ferns and leaves, using Iterated Function Systems. The code is written in Java with a custom Swing front end, tailored to OSX in particular using Apple's platform integration API. The code also uses Google's Guava library, in particular the EventBus, which is used to pass the Model data from the Controller to the View. I really like the way this just requires annotation of a method with @Subscribe to indicate the event handlers. Fairly obviously, as well, this implies I am using the MVC design pattern for the UI.

I used the automatic GitHub Pages system to host the project site. This is basically a cut-down Jekyll implementation with some default themes, but the end result is very good. The other tool I used was Travis CI to provide continuous integration. This was also incredibly simple to set up and link with my GitHub account - the only difficulty I had was reconfiguring the build to conditionally compile the OSX extensions.

Project Site for IFS Explorer 1.0.1

If you want to know more about the IFS algorithms and the maths behind them, please take a look at the references listed in the documentation or on the project site. The Gary Flake book, The Computational Beauty of Nature: Computer Explorations of Fractals, Chaos, Complex Systems and Adaptation, is particularly good, and includes a lot of other interesting stuff. The code itself is pretty straightforward, and simply makes use of the AffineTransform class in Javas 2D graphics library to implement the functions.

The application runs from a small script, which is double-clickable on most operating systems. It's really easy (and fun) to play around with due to the immediacy of rendering the IFS images, which led me to much more in-depth exploration of the possibilites than trying to generate the values for a series of transform matrices. In particular, I found it is very satisfying when a series of twisted boxes renders to produce a perfect image of a fern or Sierpinski triangle. It is possible to edit the matrix coefficients in a saved XML file though, so you could enter the values for a particular image as listed in the Computational Beauty of Nature book for example. Also, although printing is not possible yet, images can be exported as PNG files, such as the fern on the left.

The code for IFS Explorer is hosted on my GitHub account as grkvlt/iterator. Any improvements or additional features as suggested in the TODO section of the documentation would be welcome as pull requests!