.TH xmandel "" "" "X Application"
.PC "X11 interface to the Mandelbrot and Julia sets"
\fBxmandel [\-display \fIdisplay\^\fB]\fR
.PP
.B xmandel
is a user-friendly interface for generating and coloring Mandelbrot
and Julia sets.
It initially comes up with with 1 or so command buttons,
which are described below, for controlling the execution.
It draws the Mandelbrot set in the window of the initial form
when you press the
.B mandel
button.
It creates a separate window for drawing the Julia sets.
.SH Theory
The following describes the theory behind the Mandelbrot set and the
Julia sets.
.PP
Let
.I z0
be a number in the complex plane \fB(\fIx\^\fB+\fIyi\^\fB)\fR.
Choose a complex constant
.IR C .
Calculate:
.DS
	\fIz1 \fB= \fIz0 \fB** 2 + \fIC\fR
.DE
.PP
Repeat this recursively, so that \fIz2\^\fB=\fIz1\^\fB**2+\fIC\^\fR,
\fIz3\fB=\fIz2\fB**2+\fIC\^\fR, and so on.
\fIz\fB[\fIn\^\fB]\fR tends either to infinity or to zero, depending
on its initial value and the constant \fIC\^\fR.
Specifically, if the absolute value of \fIz\fB[\fIn\^\fB]\fR, 
expressed as \fB|\fIz\^\fB|=sqrt(\fIx\fB**2 + \fIy\^\fB**2)\fR
is greater than two, then the recursive formula diverges.
.PP
To calculate a Julia set, take each point near \fB(0,0\fIi\^\fB)\fR,
and use the formula \fIz \fB= \fIz\fB**2 + \fIC\fR recursively.
The Julia set is the set of points for which
\fIz \fB= \fIz\^\fB**2 + \fIC\fR
would iterate indefinitely for the constant \fIC\^\fB.
Pixels, which represent numbers in the complex plane,
are set to the number of iterations before \fB|\fIz\^\fB|\fR exceeds two.
This then becomes an index into the hardware's color map.
Each color then represents the number of iterations before
divergence is detected.
.PP
To calculate a Mandelbrot set, again take each point near
\fB(0,0\fIi\^\fB)\fR, use the same formula \fIz \fB= \fIz\^\fB**2 + \fIC\fR
recursively.
This time, let \fIC\fR be the initial value of the point itself
\fIC \fB= \fIz\^\fB0\fR).
Rather than having the same
.I C
for every point in the complex plane, as in Julia set calculations,
.I C
differs for each point in the plane.
Again, let the pixel value be the number of iterations
before \fB|\fIz\^\fB|\fR exceeds two.
.PP
On monochrome displays, the pixel value is set to one
if the iteration count is 64, otherwise zero.
.PP
The Mandelbrot and Julia sets are obviously closely
related, as can be seen from the similarity of their formulas.
If the constant
.I C
is chosen from the interior of the Mandelbrot set,
then the Julia set calculated from that
.I C
will be connected, that is, have no gaps or discontinuities.
If
.I C
is chosen from outside the Mandelbrot set,
the Julia set is disconnected, more like grains of dust (i.e., Fatou clouds).
If
.I C
is chosen from the border of the Mandelbrot set,
then the Julia set will be more convoluted.
Given this relationship between points in the Mandelbrot set
and the Julia set generated, 
.B xmandel
lets you choose
.I C
by mouse selection in the Mandelbrot window.
.SH Buttons
.B xmandel
provides the following buttons with which you can control its operation:
.IP \fK(mandel)\fR
Calculate a Mandelbrot set from (\-2.25,\-1.5) to (1.0,1.5),
and display it in the window provided.  
To terminate calculation, move the mouse cursor into the window and
click any mouse button.
.IP \fK(julia)\fR
Calculate a Julia set.
You must click the left-mouse button within the Mandelbrot window;
this gives
.B xmandel
the value of
.I C
to use for computing the Julia set.
If it needs to,
.B xmandel
opens a new window.
The Julia set is centered around (0,0),
going from (\-1.5,\-1.5) to (1.5,1.5).
You can zoom in Julia set points in Mandelbrot windows as well.
Beware of selecting points outside the Mandelbrot window.
.IP
To terminate the calculate,
click a mouse button within the drawing window.
.IP \fK(Image)\fR
After
.B xmandel
generates a Mandelbrot or Julia set, use this button to select
the image to manipulate further.
If you press this button, the active image toggles between
.B Mandel
and
.B Julia
to identify the set that is to be manipulated.
.IP \fK(zoom)\fR
To zoom in on a given area in the Mandelbrot or Julia set,
click this button.
Then, move the mouse cursor to a corner of the area on which you want to
zoom; press the left-mouse button;
drag the mouse to the opposite corner of that area;
and release the left-mouse button.
As you drag the mouse,
.B xmandel
draws a rubber-banded box to mark the area being marked for zooming in.
You can zoom in on a zoomed-in area until you reach
the limits of the precision of your hardware.
.PP
You cannot select a zoom area that crosses a window border.
.B xmandel
ignores zoom requests less than five pixels wide.
To abort the zoom request, click the center- or right-mouse buttons
while dragging the mouse.
.IP \fK(unzoom)\fR
Return to previous level of zooming.
To zoom all the way, click the button
.Kr mandel .
.IP \fK(recalc)\fR
Recompute the set at the current coordinates.
This is useful for redisplaying the current image
after you have resized the set's window.
resized.
.IP \fK(colour)\fR
This button selects colour rotation value to be applied when you click
the buttons
.K (+colour)
or
.Kr (\-colour) .
.B xmandel
adds the ``color step'' value to each pixel color before redisplay.
This effectively rotates the image through the available color map.
By default,
.B xmandel
sets the rotation value to the number of bit planes:
to eight for an eight-bit display; to two for a two-bit (monochrome)
display; and so on.
.IP
.B xmandel
``remembers'' the selected set and rotation value with the buttons
.K (+colour)
and
.Kr (\-colour) .
.IP \fK(\+colour)\fR
Positively rotate the default color set by adding the previously
specified color rotation value to all pixels.
You can create an interesting ``color zoom'' by first setting the
color rotation value to one and rapidly pressing the button
.K +colour
or
.Kr \-colour .
.IP \fK(\-colour)\fR
Negatively rotate the default color set by subtracting the previously
specified color rotation value from all pixels.
In effect, this key undoes the effect of
.Kr +colour .
.IP \fK(gif)\fR
Convert an image into GIF format and write it into a file that you name.
.B xmandel
copies Mandelbrot image if you press the
.K Mandelbrot
radio button; it saves the Julia image if you press the
.K Julia
radio button.
.IP \fK(remove)\fR
Close the Julia-set window.
.B xmandel
reopens it if you again ask
.B xmandel
to display a Julia set.
.IP \fK(quit)\fR
Exit from
.BR xmandel .
.SH "See Also"
.B
X applications
.R
.br
Gleick, James:
\fIChaos:
Making a New Science.\fR
New York, Viking Press, 1987.
.SH Notes
.B xmandel
works only with one-, two-, four-, or eight-bit displays.
.PP
Exposure events are examined after the generation of every fourth scan line:
there is some delay between an exposure event and the refreshing
of an image.
.PP
Because the libraries for X Windows for \*(CO do not use hardware floating
point, performance will be slow, regardless of whether your machine has a
floating-point processor.
.PP
.II "Freeman, John L."
.II "Field, Tony"
.B xmandel
was written by John L. Freeman (jlf@cray.com).
Changes for GIF, Motif, and System-V X11R4 were added by
Tony Field (tony@ajfcal.cuc.ab.ca).
