Partilhar via


Minh T. Nguyen's Mandelbrot Explorer in Silverlight 1.1

Update: Please refer to this new post for an updated version of this application (including source code).

Minh T. Nguyen's Mandelbrot Explorer is an application that allows you to zoom into the Mandelbrot set fractal at an arbitrary level. Simply select an area to zoom in, and use the back button to backtrace or restart button to start from the beginning. If you don't see the fractal above, please install the freely-available Microsoft Silverlight 1.1 plug-in (available for most popular browsers) using this link (the above link won't work). Note that this application is very power-hungry, so a fast computer is recommended.

Academic details: The Mandelbrot fractal is generated by drawing the set of complex numbers c on a complex plane, where the value of the function f(z) = z * z + c applied iteratively on itself is unbounded. In other words, if you pick a complex number c and an initial value of z being c, and apply the above function over and over again, you’ll see that the absolute value of the running result always remains bounded below 2 or suddenly shoots up towards infinity after a certain number of iterations. Well if the latter happens, you draw the complex number on the plane with a certain color that is reflective of how many iterations it took for the function to escape. But anyways, before mathematicians are lynching me for such a rude definition, you’re probably better off reading a formal description of the Mandelbrot set over at Wikipedia.

Technical details: This application was coded with the Microsoft Silverlight 1.1 Alpha September Refresh and is hosted via Microsoft Silverlight Streaming by Windows Live. The Mandelbrot generation algorithm is very loosely based on Marc Boizeau's implementation of using complex number classes and operator overloading, while the coloring of the complex points outside of the Mandelbrot set is borrowed from Pierre Leclercq's implementation. Since Silverlight does not support setting pixels in a bitmap, this Mandelbrot Explorer is setting tiny rectangles instead to mimic the same behavior, though some optimization have been made to reduce the number of UIElements drawn on the Canvas by recognizing neighboring pixels of the same color and drawing them all as a single rectangle. Since the Silverlight 1.1 Alpha September Refresh does not yet support marshalling the execution of code from the background thread to the UI thread (the "Invalid Cross-Thread access" exception), I had to resort to the empty timeline trick to display the progress status. The full source code for this Mandelbrot Explorer will be posted in the near future.

Personal details: So, why does the world need yet another Mandelbrot fractal generator? It doesn't. There are tons of them out there, with far more snappier UI and superior performance, but I wanted to create one to get my hands dirty with Silverlight. When .NET was still in its early stages, I coded the Sierpinski Triangle fractal to get my hands dirty with GDI+. When Silverlight came out recently, I first wanted to convert my WPF-based Sudoku 3D browser application to Silverlight, but as it turns out Silverlight does not have support for 3D geometry, so I ended up doing the Mandelbrot fractal instead. I've always been intrigued by the mother of all fractals anyways, and always wanted to learn and understand the mathematics behind it, so this was the perfect opportunity.

Comments