FractalFX is a basic program for generating basic MandelBrot and random Julia Set fractals. Programmed in Python and C, it combines the simplicity of Python with the performance of C.
The basic definition of a fractal is that it is a geometric shape that can be subdivided into smaller parts that are at least the approximate a reduced size of the original whole picture The term "fractal" was coined be polish mathematician Benoit B. Mandelbrot, who had found the famous "Mandelbrot fractal" as seen below
Information on Benoit B. Mandelbrot and his famous set can be easily on the web with the use of various search engines, such as Google or free online encyclopedias, such as Wikipedia
The fractalFx program works by combining the simplicity of python with power of C. From my experience I have found python extremely fast and easy to construct basic GUI with various widgets, which from what i hear from others is a cumbersome task in other programming languages, such as C. However this comes at a price, and that price is computing speed. For this particular objective C would be a faster choice to compute the Mandelbrot set to draw.
Determining if a point on the grid is part of the Mandelbrot is determined by Mandelbrot's equation found here. To make things simple picture the Mandelbrot set as a black box that takes an (x,y) point and assigns it a colour that determines whether it is in the set or not (black == not in set, colour otherwise). The most fascinating part is that the colour is determined on how fast it breaks from an "escape algorithm".
Since the idea behind the Mandelbrot set is established I can proceed in explaining how it is implemented. Python provides a GUI to the user which specific input is entered(such as colour scale, width and height offset etc). From here the function "Mandelbrot_execute" is called in python and executed in C. Here each pixel of the picture is assigned an (x,y) coordinate and a RGB colour based on it's "escape speed" from the algorithm. This information is stored in a tuple with 5 elements (the x coordinate of the pixel, the y coordinate of the pixel, the Red, the Green and the Blue value of the pixel). Each pixel tuple is then stored in a larger tuple that holds every pixel in the image. This image tuple acts a container for the complete information of the image and is then returned to python for further processing. Python receives this large tuple and goes through each element and extracts the necessary information for the put pixel function to draw each pixel of the image. The picture is then displayed to the user and saved to the requested file name and type.
Here is an example of the interface and an example of a grey scale Mandelbrot:
The bugs present in the program would have to be its' lack of defense against strange input. At any time a use could enter a string instead of an integer and the program would't be able to handle it.However these kind of bugs can be dealt with. Another troublesome bug would have to be the time it takes to generate the fractal. I chose to use a higher maximum number for the amount of iterations the algorithm would check for. This in turn causes the program to run longer (especially considering the program processing 800x600 pixels). A minor bug found is when a random Julia set is to be generated in a purple colour, a much different result occurs. Give it a try! It's very psychedelic.
As for shortcomings, the largest shortcoming would be the limits the user has to customize their fractal. The program allows the user to select a number of colours, but I feel it is to limited. Ideally I would of like to implement a slider bar and provide a more continuous colour range for the user to choose from, but due to time constraints and lack of knowledge in the field it was not realized. Another shortcoming would have to be the lack of different fractals the program generates. Currently it can only render two types of fractals: the Mandelbrot set and the Julia set. The similarity between the two made this possible. The Julia set is very similar to the Mandelbrot set, but in the equation that determines the coordinates of the next x and y, there are two constants added. Once again due to time and lack of knowledge additional fractals were not realized in this version of the program, but perhaps they may be implemented in the future
The entire assignment took me about five days to complete fully. This includes testing and tweaking to get the GUI and fractals to my liking. The GUI itself took me about half an hour to construct (and possibly even shorter if I had realized that an example of a similar GUI was placed on the course web site). Linking python and C was a difficult concept to wrap my head around, so this portion took me about three days in duration. (Once again, my ignorance to the material posted in the course web site shows in the time taken).Most of the three days was spent reading and re-reading the documentation on extending and embedding.The final two days was spent on trying to get the pseudo to be more than just pseudo-code and figuring out a method to transfer the pixel information from C back to python and how to implement this method.