Project 1.B: Mandelbrot Set

This is the second installment of your Mandelbrot project. Do not wait until the last minute to work on the project deliverables. You may suffer in many ways if you do. This is an individual project. As always, I encourage you to talk to your peers or to me and to ask questions. But the code you submit must be your own code.

In this deliverable, we will complete a simple interface to zoom into and out of the picture These represent modifications to your code from deliverable one. You should still have a primary Mandelbrot1 class with a main method that draws the image.


  1. Extending from Project 1.A. Start a new class, Mandelbrot2, that extends your Mandelbrot1 class. You may make minor modifications to your Mandlebrot1 class, such as changing the access of fields and methods.

  2. Determine rate of divergence. [If you have already done this, great!] If you have not done so already, alter your inMandelbrot function to return an int instead of a boolean. The returned int should indicate the number of iterations performed prior to the time at which the complex value diverged. This number determines the color used to render the corresponding pixel.

  3. Colorizing the picture. Instead of a two-color image, you should now draw the set with a range of colors. [Again, you may have done this already.] You should color pixels of your canvas according to rate of divergence for the corresponding point in the complex plane; that is, if a point diverges after four iterations it would get colored in one color and if after forty iterations then some other color. You should think about how best to map the numbers onto colors. Review the java.awt.Color class for some ideas. Consider both smooth and stark transitions between colors in order to improve the aesthetics of your images.

  4. Navigating into and out of the image. Your program should allow the user to zoom into the image by left-clicking the mouse on a point. Upon a left-click, the program should re-draw (re-render) a region that is half the size in the complex plane (but still rendered on the same WIDTH by HEIGHT canvas). This new region should be centered on the point where the mouse was clicked. Similarly, if the user right-clicks on a point, zoom out with a region twice as large and centered on the point that was clicked.

  5. Finalized packaging. For the code you submit, use default values: max iterations of 256 and a window size of 900x600. However, you should support optional command-line arguments for alternate max-iterations and window size width. (That is, use that “String[] args” that we've had present in our main methods all along. If one argument is provided, interpret that as the desired max-iterations. If two arguments are provided, interpret the second as the desired window width (determine the height so as to maintain a 3:2 aspect ratio).

Submission Instructions:

Important: Include your whether or not you modified it for this assignment! Do not forget to use the javadoc constructs for your documentation and include the html file produced by the javadoc tool in your final submission. Make sure that you create a folder named with your Westmont email name followed by “P1B”. For example, someone with email address “cjones” would create a folder called “cjonesP1B”. Make sure that inside that folder you have: java source files and html documentation files resulting from javadoc. Finally, either tar or zip the folder so that when we extract it, the folder “<emailname>P1B” will be created. Submit the packaged file for project 1.B on Eureka.