Minh T. Nguyen's Mandelbrot Explorer 1.0 in Silverlight 2.0 with 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 the restart button to start from
the beginning. If you don't see the fractal above, please install the
freely-available Microsoft Silverlight 2.0 plug-in (available for most
popular browsers) at www.silverlight.net. 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 either 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 recently updated with the Microsoft Silverlight 2.0 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. In order to draw pixels on a Bitmap in Silverlight, I used Joe Stegman's dynamic image generation code.
Source code: The full source code for this Mandelbrot Explorer is posted here (requires
Visual Studio .NET 2008). I don't care what you want to do with this.
Just don't make money or claim that it's yours. :)
Version 1.0 Update: This 1.0 version is an update over the 0.9 version.
It uses Silverlight 2.0's new DispatcherTimer to be able to modify UI
elements from a timer event without the need to manually marshal
control back to the UI thread (avoids the “cross-thread operation not
allowed” exception). In addition, in version 0.9 I used a bad hack of
drawing tiny rectangles on a canvas to mimic pixels since Silverlight
does not have an out-of-the-box editable image class. Well, since then Joe Stegman has invented such an EditableImage
by converting the pixel data in memory into a PNG image. This technique
greatly improves the drawing performance, prompting me to even draw the
view partially as it is being calculated. What's next? Well, really, I
should be coding this using the DeepZoom technology, since this example is just crying out loud to be implemented using that, but I'll do that another time. :)