
One of the "copies" of the Mandlebrot Set floating somewhere around its outside edge.
And now for something completely different! The Mandelbrot Set! This is the basis for all those paisley computer fractal pictures we see everywhere, especially when they were popular in the 1990s. For your viewing pleasure, a Mandlebrot explorer app is included, with (Flash) source, right down there in this blog post! Woo!
In this article, I’m going to talk about how the images are generated, and use that as an example of something I find I do quite commonly: remapping number ranges. High excitement, there.
I do apologize in advance that this post is a bit mathy. Now, I was never particularly good with math, so I figure that if I’m grasping it, it must be pretty straightforward (the actual manipulations never get beyond elementary algebra.) But it’s not as easy reading as, say, Captain Blood. If you don’t care for math, I encourage you to just jump, guilt-free, down to the pseudocode and the app! Enjoy!
Read more…

A horizontally-interlaced image, after 3% of the data has been displayed.
Let’s say you were going to write an app that rendered a complex image one pixel at a time, and that rendering would take about, say, 10 seconds per image. Or lets say you were downloading a large image and it would take, say, 80 seconds to download the whole thing.
80 seconds in 2010, is equivalent to approximately 37 years in the year 12 BC, and is entirely an unacceptable amount of time to wait to see the whole image.
What can you do? You can interlace the image data. Instead of just producing the pixel data linearly left-to-right, top-to-bottom, you produce it out-of-order with big gaps, so that you get a representative subset of the final image first, draw that, then get another pass of data and use that to improve things further, then another pass, and so on until your image is complete. This enables you to draw a low-resolution version of the image after a very short amount of time, and then keep improving it over the course of the data generation (whether it’s a download or a calculated image rendering).
Read more…