Archive for September, 2007

Real-time Mandelbrot set zooming

Thursday, September 6th, 2007

A while ago, I discussed a data structure which makes real-time Mandelbrot zooming possible. I finally got around to implementing it and the result is here (source code). Windows only for now, but it could be ported to other platforms with some effort.

As well as real-time zooming, the program has a logarithmic palette, progressive resolution, progressive dwell limit and anti-aliasing.

The program should run on Windows 98 or later and has no dependencies. It uses GDI for drawing - DirectX is not needed. It'll work best if your video mode is set to 32-bit colour depth. It's reasonably fast on my 2GHz Core Duo machine (even though it only uses one core at the moment), but the faster your machine the better. It can be a bit memory hungry (I've seen it use over 200Mb for a detailed 1600x1200 image).

The program is controlled with the mouse - hold down the primary button to zoom in, the secondary button to zoom out and drag with the middle button to pan. I was surprised to learn after implementing them that they are exactly the same as for XaoS. I'd like to think that it's convergent evolution but I probably just subconsciously remembered them from the previous time I used XaoS some months previously.

If you zoom in too far (by a factor of 30 billion or so) you'll reach the limit of double-precision arithmetic and the image will dissolve into rectangles. Eventually I plan to implement multiple precision arithmetic which will make it possible to zoom in much further. Though there will always be a practical limit of just how long it takes to multiply two numbers of sufficient precision.

If you leave it for a while without zooming it will gradually refine the image to sub-pixel level and make some really gorgeous images. It will calculate faster if the window is covered up - redrawing is quite slow, especially once the image is quite highly refined. This is also why the zooming is a bit jerky if you leave it for a while. I'm thinking of ways to improve the rendering speed - I'm wondering if I can do better (at least for highly refined areas) by rendering to a grid-aligned array first and then resampling, instead of rendering each block directly.

I've experimented with SOI (using linear interpolation and a quadrilateral method for divergence detection) but so far it doesn't seem to make much difference (though the fact that it doesn't slow things down terribly is encouraging). This version doesn't include those experiments. Perhaps I need to use a higher-order method. AlmondBread and Fractint use quadratic interpolation. I'm wondering if better results can be achieved by iterating some derivatives of the Mandelbrot formula instead of extra points. Then I wouldn't need to interpolate at all - just evaluate the Taylor expansion when I need to subdivide. And divergence detection would just be a matter of looking at the highest order derivative.

Software downloads

Thursday, September 6th, 2007
  • These are all for IBM compatible PCs running DOS and/or Windows. They will not run on any computer named after a piece of fruit or any operating system which has the letter 'X' in the name (probably). Some of the DOS programs will have problems running under Windows.
  • They are all compressed with PKZIP. You need PKUNZIP or another program that can decompress .ZIP files to be able to use them.
  • The Windows programs may require a DLL (Dynamic Link Library) that you don't have. If this is the case, try here.
  • Please don't write and tell me that the documentation for some of these programs is very bad - I know. Some of them don't have documentation at all. I wish you fun trying to figure out what they do.
  • Download sizes are given in brackets. To calculate approximate times in seconds, divide the size (in Kb) by your connection speed (in Kbps) and multiply by 10. That's the approximately the theoretical maximum speed.
  • Warning: Never run software you have downloaded from a site you do not trust! Whilst every precaution has been taken to ensure that these files do not contain viruses, I recommend running a virus checker that you trust on the files once they have been unzipped (.ZIP files cannot carry viruses, only their contents can). However, even a virus checker will not tell you if the files they are checking have been specifically created to cause havoc (trojans) I promise that none of the programs I've uploaded here are trojans. If you don't trust me, get the source, understand it and compile it yourself with a compiler you trust.
  • Full source code for all these is available on the free software principle:
    • Use it
    • Change it, just don't hoard it.
    • Sell it if you like, although I'd appreciate a cut of the profits.
    • Please don't remove my name from it.
    • Whatever else you do, just don't hoard it.

    At the moment you'll have to email me for the source because it's too messy to upload. Hopefully I will get around to fixing that soon.

[New Sep 2007!] Mandelbrot zoom (160K) - a fractal program for Windows featuring a logarithmic palette, progressive resolution and dwell limit, anti-aliasing and real-time zooming. For best results ensure your colour depth is set to 32-bit. Source code (30K).

Digger - Classic arcade action game - Click here for more info
Cool Dude I (190K) - Massive action/adventure game
Screen Designer (36K) - For CD1, batch files and DOS programs
Character Designer (68K) - ideal for Windows icons, games design, etc. Very powerful.
Binary File Editor (22K) - Change individual bytes in files
Fractal trees/clock and 3D salt model (52K) - Demos: require VGA
Address book (15K) (Windows)
Interest calculator (3K) (Windows)
Oscilloscope for Soundblaster (21K) - see your voice in real time!
MAZE-O-TOUR (23K) - beautiful smooth scrolling VGA game
Freecell for DOS (38K) - 16 bit DOS version of the addictive Microsoft Win32 game.
DSPACE (13K) - useful program which shows you which directories/extensions are taking up all your hard disk space
LIFE (19K) - Obligatory cellular automata program. One of my earliest programs.
Tetris (39K) - Fast action game.
Miscellaneous DOS utilities and screen programs (68K)
VGA Demos (169K) - pretty animations
Date calculator (10K) - Want to know when your next 1000-day birthday is, or when you will have known someone half your life? This will help.
Date calculator for Windows (4K)
Text utilities (25K) including ROT13, WORDWRAP and a utility for fixing files saved on Apple Macs.
Disk utilities (11K) SERIAL, ABSDISK, QFORM and ROOTSORT. Be sure to read README.TXT before using these.
Q7 (7K) A puzzle.
SETKIPS (6K) Program to slow down new computers for running old games. Better than Mo'Slo with some programs, and free!
KEYB (5K) Tiny program to turn your computer keyboard into a musical keyboard: with true polyphony and multiple instruments. Doesn't even need a sound card.
Words (20K) Flashes (in big, pretty letters) random inspirational words until you press ESC. A result of my playing with the FreeType library.
Runsaver (3K) (Windows) use any program (DOS or Windows) as your screensaver.
Rockfall (12K) - Clone of "Drop Zone".
Mr X (19K) - Clone of "Orby" and precursor to Cool Dude. You'll probably want to change the speed - 500 is the default and higher numbers are slower.
Watermargin (10K) - Two player board game.
Sliders (7K) - Someone challenged me to write this game using as little code as possible.
Disasm (41K) - Intelligent disassembler for all 80x86 compatible processors up to and including the Pentium III. Not quite finished yet (it's going to be interactive) but still more useful than DEBUG (even more useful than Sourcer in my opinion).
GRABBMP/REPLCBMP (19K) - A suite of programs to extract windows bitmaps (BMP, ICO and CUR) from files in which they are embedded (usually EXE and DLL) and replace them once you've edited them.
DbxTool (84K) - A program to extract messages from "dbx" files (Outlook Express message folders). If you came here looking for "Defunge", download this instead - it's better.
run_random (99K) - A program to run a random file from a directory.
crc32 (112K) - A program to enumerate files in a directory and find their CRC32 checksums.
Bifurcation fractal (117K) - A program to render the Bifurcation fractal.

The Sopwith source code, which used to be here, has moved to