Aptus is a Mandelbrot set viewer and renderer. It is written in Python with a computation engine in C for speed.

A portion of the Mandelbrot set

Getting Aptus

Pre-requisites

Aptus installs like any other Python package. Before installing Aptus, you'll need to install these prerequisite Python packages:

Installation

Download the kit that's right for you. Linux and Mac use the tar.gz, Windows users will probably be happier with the .exe:

Download: Aptus-2.0.tar.gz
Download: Aptus-2.0.win32-py2.5.exe

Install the kit with the usual command:

python setup.py install

Source

The source is available on bitbucket if you prefer direct access to the code, including recent changes.

Using Aptus

There are two ways to use Aptus: a GUI explorer, and a command line renderer. The GUI lets you zoom in and out, and change the color palette to find an image you like. The command line renderer produces higher-quality images.

Parameter files

Aptus stores information about the image to display in a few ways. Small textual .aptus files store all the parameters needed to recreate an image, and can be saved from the GUI and fed to the command line renderer.

When saving an image as a .PNG file, Aptus also stores all its parameter information in a text block hidden in the image, so that the .PNG can be used directly as a parameter file.

Aptus can also read Xaos .xpf files so that you can use Xaos to explore, and Aptus to render if you like.

GUI usage

Start Aptus with aptusgui.py, and start poking around. Left click or drag zooms you in, right click zooms you out. Type 'h' for help on other controls. Detailed descriptions of GUI behavior are below.

aptusgui.py also accepts applicable command-line switches so you can start it from a parameter file, or specify the size of the window, and so on.

Command line usage

The command line renderer is called aptuscmd.py. It will accept a number of switches or parameter files:

Usage: aptuscmd.py [options] [parameterfile]

Aptus renders Mandelbrot set images. Two flavors are available: aptusgui.py
for interactive exploration, and aptuscmd.py for high-quality rendering.

Options:
  -h, --help            show this help message and exit
  -a ANGLE, --angle=ANGLE
                        set the angle of rotation
  -b BAILOUT, --bailout=BAILOUT
                        set the radius of the escape circle
  --center=RE,IM        set the center of the view
  -c, --continuous      use continuous coloring
  --diam=DIAM           set the diameter of the view
  -i ITER_LIMIT, --iterlimit=ITER_LIMIT
                        set the limit on the iteration count
  -o OUTFILE, --output=OUTFILE
                        set the output filename (aptuscmd.py only)
  --phase=PHASE         set the palette phase
  --pscale=SCALE        set the palette scale
  -s WIDxHGT, --size=WIDxHGT
                        set the pixel size of the image
  --super=S             set the supersample rate (aptuscmd.py only)

GUI controls

The Aptus GUI is very bare: there's just an image of the Mandelbrot set, with no visible controls. You use the mouse and keyboard to control Aptus.

Moving around

Left-clicking zooms into the set, right-clicking zooms out; clicking while holding the Ctrl (or Cmd) key zooms just a little bit. If you drag out a rectangle with the left mouse button, you will zoom into that rectangle, so you have more control over exactly where you end up.

If you drag with the middle mouse button, you will drag the image, re-centering it on a new point of interest.

The 'a' key will prompt you for a new angle of rotation for the image.

The 'n' key will open a new top-level window to explore elsewhere in the set.

Appearance

The image of the Mandelbrot set is drawn by calculating a value at each pixel, then mapping that value to a color through a palette. The values can be discrete or continuous — use the 'c' key to toggle between the two.

The accuracy of the black boundary of the set depends on the number of iterations Aptus is permitted to calculate at each point. The value can be adjusted with the 'i' key.

Aptus has handful of different palettes. Cycle through them with the '<' (less-than) and '>' (greater-than) keys. A list of all the palettes can be displayed with 'p'. The color mapped to each value can be shifted one color with the ',' (comma) and '.' (period) keys. If the pixel values are continuous, then the palette can also be scaled to change the distance between color bands — use the ';' (semicolon) and "'" (apostrophe) keys, optionally with the Ctrl key to change just a little.

The hue and saturation of the palette can also be shifted. The '[' and ']' (square bracket) keys change the hue, and '{' and '}' (curly braces) change the saturation. Both also use the Ctrl key to change just a little.

The '0' (zero) key will reset all palette adjustments.

Auxiliary windows

Aptus has a few tool windows. Each is toggled with a particular key.

'p' displays a list of all Aptus' palettes. Clicking one will change the display to use it.

'v' displays a list of statistics about the last fractal calculation.

'q' displays information about a point in the display. Hold the shift key and hover over a point in the image to see iteration counts, coordinates, and so on.

'l' (lowercase L) displays the You Are Here panel. It shows a series of images, zooming in to the currently displayed view of the set. Each image has a rectangle drawn on it corresponding to the next image in the list, so that you can see how your close-up view in the main window relates to the larger set. Any rectangle can be dragged to change the main window's view of the set.

Julia set

The Julia set is closely related to the Mandelbrot set. Each point in the Mandelbrot set corresponds to a Julia set. To display the Julia set, use the 'J' key (with the shift key). A small tool window appears. It shows the Julia set for the current shift-hovered point in the main window. Hold the shift key and move the mouse over the Mandelbrot set. The Julia set will change as the mouse moves.

To further explore a particular Julia set, double-click in the Julia set window. You'll get a new top-level window displaying the Julia set, and you can use all the usual Aptus controls to navigate and manipulate the image.

History

Version 2.0, October 2008

  • Multiple top-level exploration windows.
  • Tool panels show supplementary information:
    • You Are Here shows your location in the Mandelbrot set.
    • Palettes panel shows all the palettes, and the one currently in use.
    • Statistics panel shows statistics about the latest computation.
    • Point Info panel shows information about the current point, shift-hover to indicate point.
    • Julia panel shows Julia set for the current point, shift-hover to indicate point. Double-clicking the Julia panel opens a new exploration window to explore that Julia set.
  • Computation improvements:
    • Faster.
    • The exploration window updates during computation.
    • Continuous coloring is more accurate now: banding artifacts are gone.
    • When dragging the exploration window, pixels still in the window aren't re-calculated.
  • Center and diameter can be specified in the command line arguments.

Version 1.56, April 2008

More display improvements and simplifications. Thanks, Paul Ollis.

Version 1.55, April 2008

The display is now flicker-free. Thanks, Rob McMullen.

Version 1.51, March 2008

Fixed a few bugs, including not drawing at all on Mac or Linux!

Version 1.5, March 2008

A number of improvements:

  • Continuous coloring.
  • Arbitrary rotation support.
  • Middle mouse button drags the image.
  • Palette tweaking:
    • Hue and saturation adjustments.
    • Scaling the palette to adjust distance between colors.
  • Statistics:
    • More statistics: boundaries traced, boundaries filled, and points computed.
    • Statistics are written into the final .PNG files.
  • Reads .xet files from servebeer.com.
  • Some old .aptus files recorded the y coordinate incorrectly, and will now render upside-down: negate the y component of the center to fix this.

Version 1.0, October 2007

First version.

More samples

A portion of the Mandelbrot setA portion of the Mandelbrot set
A portion of the Mandelbrot setA portion of the Mandelbrot set

See also

  • Xaos, a full-featured fractal explorer which has many more rendering and fractal options than Aptus.
  • Gnofract 4D, a Linux-based fractal exploration program.
  • My blog, where recreational math and Python topics intersect from time to time.

Comments

[gravatar]
Gustaf Erikson 10:11 AM on 13 Oct 2007

Hi! Sounds like an interesting app. I've been fascinated by fractals since learning about them in high school, lo these many years ago.

I've tried installing the app in Ubuntu Linux. It's compiled and installed. However, when I run

$ python /usr/bin/aptusgui.py

I get a gray window and a bunch of error messages to the console. The central error is

RuntimeError: Failed to gain raw access to bitmap data.

I think I've got all the prerequisites installed, otherwise I shouldn't have been able to install it, right?

Thanks,

/g.

[gravatar]
Rob McMullen 12:02 PM on 18 Mar 2008

I was experimenting with a numpy version, and wanted to see if I could code up a faster version in C. The obligatory google search turned up your version; well done!

A segfault turned up on my amd64 machine with python 2.5: I had to change "int ncolbytes" to "Py_ssize_t ncolbytes" (line 504 in engine.c). It looks like the API for PyString_AsStringAndSize changed between python 2.4 and 2.5...

[gravatar]
Ned Batchelder 9:32 PM on 18 Mar 2008

Rob, thanks for the micro-patch. The problem wasn't the change from 2.4 to 2.5 (I build Aptus under 2.5), but that I am using a 32-bit platform where there is no difference between Py_ssize_t and int.

[gravatar]
Chetan Nichkawde 1:52 AM on 2 Apr 2008

Hi,
I installed the thing. However, whenever I start I get following :

manager@mac03:/srv/home$ aptusgui.py
: No such file or directory

I do not what command line arguments to pass (if any). I just want to get started.

Chetan

[gravatar]
Ned Batchelder 5:54 AM on 3 Apr 2008

@Chetan: the problem is a DOS line-ending in the aptusgui.py file (and aptuscmd.py). I'll post a new kit shortly with the problem fixed. In the meantime, you can either edit the file yourself, or run the commands as "python /path/to/your/aptusgui.py"

[gravatar]
Chetan Nichkawde 6:15 AM on 3 Apr 2008

Thanks! Its works. Great piece of art.

[gravatar]
Albino 1:17 PM on 1 Apr 2009

I've installed your app, however, there is no aptusgui.py nor aptuscmd.py in the aptus folder in the site-packages directory. Is there any problem with the installer or is it incompatible with windows vista?

[gravatar]
Ned Batchelder 2:15 PM on 12 Apr 2009

@Albino: The aptusgui.py and aptuscmd.py files are in the \Python\Scripts directory, not site-packages.

[gravatar]
Adam 2:58 PM on 19 Jul 2009

Hi. Thx for program. Your coloring algorithm looks great. Could you describe it ? ( or where in code I can find it ). Best regards

[gravatar]
Ned Batchelder 3:27 PM on 26 Jul 2009

@Adam, thanks. There's no innovation in the coloring algorithm, I just used techniques I'd read about other places. Maybe the palette is what you are after, and that's all in palettes.py

[gravatar]
Lee Harr 1:02 PM on 19 Jan 2010

I ran Aptus on my home computer and it works great. Now at work I am also getting the error about bitmap data:

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/aptus/gui/viewpanel.py", line 182, in on_paint
self.bitmap = self.draw_bitmap()
File "/usr/lib/python2.6/site-packages/aptus/gui/computepanel.py", line 165, in draw_bitmap
return self.bitmap_from_compute()
File "/usr/lib/python2.6/site-packages/aptus/gui/computepanel.py", line 155, in bitmap_from_compute
bitmap = wx.BitmapFromBuffer(pix.shape[1], pix.shape[0], pix)
File "/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_gdi.py", line 856, in BitmapFromBuffer
return _gdi_._BitmapFromBuffer(width, height, dataBuffer)
RuntimeError: Failed to gain raw access to bitmap data.


Looks like a wx problem, but googling that message is not helping...

[gravatar]
Ned Batchelder 6:37 AM on 20 Jan 2010

I don't know what the error "RuntimeError: Failed to gain raw access to bitmap data" means. It's used for any error encountered while creating a raw bitmap, so it could be a low-memory situation.

[gravatar]
James Pannozzi 4:48 PM on 9 Nov 2010

This comment in the wrong place but anyway, saw your apl1 and apl2.png in /pix. I experiment with APL2 now and then, it's interesting.
Any more sample code please post. Am using APL2/PC DOS, with various tricks on Linux dosbox, have a 32 Meg workspace.
Python code here interesting too. Heard that BM passed away, too bad, amazing guy.

[gravatar]
Anandaram 12:28 AM on 11 Feb 2011

Hello:
I tried to install Aptus.exe file in Windows.
It refused saying python25 was required. But I have python26
as part of pythonxy 2.6.5.6 which works well in my Win 7 OS.
So can you make Aptus run in py2.6/2.7 etc?
Thank you
Anandaram

[gravatar]
Adam 9:48 AM on 27 Mar 2011

Hi. I'm trying to install Aptus. After :
adam@adam-laptop:~/Aptus-2.0$ python setup.py install
there are some problems :
...
building 'aptus.engine' extension
creating build/temp.linux-x86_64-2.6
creating build/temp.linux-x86_64-2.6/ext
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/python2.6/dist-packages/numpy/core/include -I/usr/include/python2.6 -c ext/engine.c -o build/temp.linux-x86_64-2.6/ext/engine.o -O3 -fno-strict-aliasing
ext/engine.c:5:20: error: Python.h: There is no such file or directory

It makes impossible tu run aptus :

adam@adam-laptop:~/Aptus-2.0$ python /home/adam/Aptus-2.0/scripts/aptusgui.py
Traceback (most recent call last):
File "/home/adam/Aptus-2.0/scripts/aptusgui.py", line 2, in
import aptus, aptus.gui, sys
ImportError: No module named aptus
adam@adam-laptop:~/Aptus-2.0$ python /home/adam/Aptus-2.0/scripts/aptuscmd.py
Traceback (most recent call last):
File "/home/adam/Aptus-2.0/scripts/aptuscmd.py", line 2, in
import aptus, aptus.cmdline, sys
ImportError: No module named aptus

What can I do ?

Regards

[gravatar]
Ned Batchelder 10:28 AM on 27 Mar 2011

"Python.h: There is no such file or directory" -- you need to install the python-dev package with your OS package manager.

[gravatar]
Adam 10:37 AM on 27 Mar 2011

Thx. It works now. I have only use (on Ubuntu) :
sudo python setup.py install

Regards

[gravatar]
Adam 3:05 PM on 28 Mar 2011

This link is dead :
http://hbar.servebeer.com/mandelbrot/coordinates.html
The requested URL /mandelbrot/coordinates.html was not found on this server.

[gravatar]
Renaud 3:53 PM on 22 May 2011

Install works (W32). Result is great. Thank you for sharing sources.

[gravatar]
Owen Maresh 10:30 PM on 21 Aug 2013

Nice, worked out of the box. The only modification I can think of (and don't know how to implement off the bat), is that it would be nice if places where it's gray (because there's too many color changes happening to keep up, could be made black and antialiased).

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.