Skip to content


A QT Project – Fractal Generator – Zoom

I implemented zoom for Arthur. Now the selection can be used to zoom in or out. In order to do that I had to make some mapping between the mouse coordinates, the pixmap coordinates and the fractal coordinates. Check the mouseReleaseEvent method in arthur_canvas.cpp. When the mouse is released I calculate the pixmap coordinates inside the widget. With the help of this info I calculate the selection coordinates in terms of pixmap coordinates and pass them along with the selection width and height to a new function in the ArthurFractal class, which performs the zooming.

Check the zoomToPixels method in arthur_fractal.cpp. It maps the selection coordinates to the new complex corner coordinates of the fractal. Then it calls calculate.

I also had to change the selection a bit. In order to keep the aspect ratio of the fractal I had to force the selection to keep the aspect ratio of the rendering pixmap (which is actually equals the aspect ratio of the fractal). Check the mouseMoveEvent in arthur_canvas.cpp for details.

I also made some slight modification to the GUI. In Designer I changed the border width of the central widget of the main window. to zero. Now, I think it looks better.

Here is a screenshot of the zoomed Mandelbrot:

You can download the sources here: fractal007

Posted in Arthur Fractal Generator, QT Programming.

Tagged with , , , .