CSE 557: Computer Graphics

Winter Quarter 1997


Project 0: Mandelbrot


Date Assigned: Monday, January 6
Date Due: Monday, January 13

Project objectives

The purpose of this assignment is primarily to give you some experience with using the Indys, the CaseVision development environment, OpenGL, and libui, the user interface library. You'll also learn about using indexed color and color tables, as well as make some interesting pictures.

The assignment itself is a gentle exercise in 2D data visualization. You'll be using the iterated quadratic transformation associated with the Mandelbrot set as a source of data for your images. The Mandelbrot set, M, is the set of complex numbers such that for any c, an element of M, the infinite series defined by iteration of the equation

z = z^2 + c
is finitely bounded. Points lying outside of M in the complex plane, when iterated as c in this equation, yield sequences of z's that diverge. Traditionally, points in the Mandelbrot set are colored black, and bands of points around the set are colored according to how quickly they diverge. The Mandelbrot set exhibits a complex fractal structure at its boundary. Unlike some other forms of fractal curves, its hallmark self-similarity is more broadly thematic than strictly repetitive. As you zoom inifinitely into the boundary, the patterns you see, while suggestive in form of larger scale patterns in the distribution of the set, never exactly repeat those patterns.

To get started, click here to run the install program, or (when that doesn't work) make a copy of the directory /cse/courses/cse457/projects/mandelbrot. (Note that you want to copy the files to your account on the Indys, not on wolf, lynx, or grizzly.) After you've read over this assignment description, check out the Project 0 help session for introductory tutorials on making a home page, OpenGL, libui, and CaseVision. Also, now may be a good time to check out the sample solution.

Required extensions

  1. Fill in the code of the dummy procedure calculateFractal to loop through the complex plane, storing the number of iterations it takes each point to diverge (you are given a function that determines this number for you). Use these numbers as indices into a color table to draw a color Mandelbrot set (a color table is defined for you).
  2. When the window for mandelbrot is obscured by another, information in the drawing area is lost and must be redrawn when next exposed. Handle this by filling in the code for exposeCallback.
  3. Fill in the code of the procedure zoomCallback. This should change the range of the computational plane, and then recalculate the set for this range.

Bells and Whistles

One bell is worth two whistles

[Whistle] Even though the Indys are very fast, there is still a considerable delay when zooming in while the mandelbrot is recalculated. Improve zooming by first zooming to a coarse, pixel-stretched version, and then sharpening to the recalculated set. For an extra [Bell], make zooming interactive: instead of using a zoom window, have the user drag the mouse to zoom in at a coarse resolution. Then, when the user lets go of the mouse, the Mandelbrot set visualization is recalculated.

[Whistle] A clever hack for playing with indexed color is to shift the entries in the color table and make the colors "animate." Implement color cycling as a "time out" procedure.

[Bell] The starting point already comes with a nice color palette. Add an option to use different palettes.


[Bell] Zooming in is a fairly easy computation; zooming out is a bit harder. Allow a user to zoom out: zooming in once and zooming back out with the same rubber-band box should bring you to the exact same place.

[Bell] Instead of calculating the visualization for the entire range, have a procedure to calculate one row at a time. If you make this an "Idle Procedure," a user can operate the controls while the Mandelbrot set is being calculated.

[Bell&Whistle] Allow a user to pan around the image. Your algorithm should be smart enough to copy redundant pixels and only calculate unknown information.

[Bell&Whistle] Add an option to allow a user to save the image as an .rgb file.


[Bell&Whistle] There is only one Mandelbrot set, but there is a Julia set associated with the same quadratic iterator for every point in the complex plane. Implement a feature so that when a user clicks on a point, the Julia set for that point is calculated.

[Bell] [Bell] Investigate more intelligent methods of looping through the complex plane. One possible solution is to employ a divide-and-conquer algorithm that fills in large, similar areas of picture. Another possible solution is to use contour tracing; i.e., trace around the edge of the Mandelbrot set first, and then trace around each surrounding ribbon.

[Bell] [Bell] Mathematically, you can infinitely zoom into a Mandelbrot set and still have an interesting picture. This breaks down, however, when using indexed color and a small number of iterations -- after a while no new detail is revealed. Implement a way to dynamically change the number of iterations, with either a user-controlled slider, or a more intelligent method. (Remember you'll need to update the color table as well!)

And Finally...

When you are finished with this assignment, you will probably want to remove the executables and object files from your copies of the directories. To do this, a "make clean" option is available in the Makefiles.