Quite some time ago I decided to learn how to program idiomatically in C++. A great resource were the C++ Annotations by Frank B. Brokken, which by the way are also in Debian’s repositories.
My first and only project in C++ was to write a fractal renderer. I wanted to do something idiomatic, so I started creating classes upon classes abstracting everything that I can think of (the function to be iterated, the convergence criterion, the visualization method, etc). At the end I got something interesting, working and amusing. However I am not sure whether I reached the goal of getting it done idiomatically. Moreover, the program is certainly on the lower end performance-wise.
Anyhow, here is what it was capable of:
- Mandelbrot fractals of any order ( for any and not just 2), Mandelbar fractal, etc.
- The dual Julia fractals.
- Various coloration schemes.
- Superimposing Julia fractals over the Mandelbrot fractals.
- Getting some quite useless 3D visualizations.
- Getting feedback on the convergence.
- Zooming and panning of course.
One drawback is that I based the image manipulation and the GUI event loop on CImg, which was an overkill and its api is constantly in a flux. Hence I have to fix the api calls every time when I want to compile the code as this is once every few years and I can never find the version of CImg for which the original was written.
The code can be found on my gitorious page.
And here are some renderings.
The last one that seem grainy are actually downscaled superpositions of Julia over Mandelbrot fractals. You may try to zoom on them. The original was 10000×10000 pixels.