Skip to content


A QT Project – Fractal Generator – Palette Rotation

Adding palette rotation to Arthur was fairly easy. All I had to do is to add some buttons to the UI for stepping and rotating back and forth and an additional stop button for stopping rotation. Then I connected the action handlers to the buttons. Since I handle the image as an indexed image, stepping the palette means stepping the colors in the palette. So I implemented a step forward method, which copies every color in the palette one position forward and copies the last color to the first place. I also made another method that does the same in the opposite direction. When I need step, I simply call the corresponding method. When I need continuous rotation I need to call these methods again and again. So I implemented the methods as slots. I introduced timers for the forward and backward rotation. And in the canvas constructor I connected the timer event signals to the corresponding palette step slots. The rotation activation means starting the corresponding timer. Stopping is just stopping the timer. Easy, isn’t it?

Here is a screenshot about Arthur with its new palette buttons:

Here is an animated GIF. I saved the frames as PNG images from Arthur. I made one forward palette step before saving the next frame. Then I used GIMP to make an animated GIF from the PNGs.

You can get the sources from here: fractal013

Posted in Arthur Fractal Generator, QT Programming.

Tagged with , , , , .