This example shows how to draw a Phoenix set fractal, a shape that was discovered by Shigehiro Ushiki in 1988. The fractal is generated by iterating the equation:
Zn+1 = Zn2 + Re(C) + Im(C) * Zn-1
Where the Zs and C are complex numbers, C is a constant, and for a point (X, Y):
Z0 = 0 Z1 = 0 C = X + Yi
The program iterates this equation until the magnitude of Zn is at least 2 or the program performs a maximum number of iterations. It then uses the number of iterations as an index into an array of colors to set the pixel’s color.
This example provides a lot of other features such as the ability to zoom in and out and the ability to select the colors used. See the code for details.