Fractal - Mandelbrot SetThe past two days I've been working on a small application that draws the famous
Mandelbrot set and lets you zoom in quite a bit.
I hope you like it and I'm always open for questions, discussions, requests, suggestions, etc.
Impressions DownloadHow to Use- One can zoom-in with the mouse by selecting a rectangle on the window.
- The arrow keys [Up] and [Down] can be used to raise or lower the precision value shown in the top left.
- The [Return] key will force a rerendering of the fractal.
Technical DetailsFor those interested in how I do things in the background, I'll say a few words here and if you're really interested checkout the
source.
I use two classes; the first one is a simple Application class, which creates a window, handles the input, drawing and managing of the resources and objects. The second one is the Fractal itself. It's derived from
sf::Drawable and thus can be directly drawn onto the window. Within the class I'm using a
sf::Sprite to render the generated texture. Since the fractal is actually a mathematical concept from which we define a way to convert the numbers into pixel information, I have to set every pixel by hand. For this procedure I'm using a
std::vector of
sf::Uint8 and call
update() on the texture by directly accessing the underlying array of vector (C++11 feature
vec.data()).
The part that consumes most of the time is the calculation and to speed things up I simply split up the screen into rectangles and run the calculations ins separate threads. Unfortunately the speedup isn't as good as one would want it to be, so I'll have to investigate further.
For further questions, just ask.
What's next?- Code cleanup. At the moment the code is still quite messy and needs some refactoring.
- Nicer default colors settings. The current settings don't create the nicest compositions.
- Interactive and user-defined color settings. The user should be able to change the colors the way he wants.
- Optimization and trying to get a deeper zooming level.