import java.lang.*; import java.awt.*; import java.applet.*; import java.awt.event.*; import java.awt.image.*; public class MandelbrotComplet //implements Complet { private double xLL, yLL, // lower left corner of region edge; // edge length of region private int res, // resolution: discretize region // into a grid of res X res squares // res & atom must be powers of 2 lim, // iteration limit cnt[][]; // iteration count for each "point" public MandelbrotComplet(MandelbrotCompletArgs args) { xLL = args.xLL; yLL = args.yLL; edge = args.edge; res = args.res; lim = args.lim; cnt = args.cnt; } public void compute() { double gap = edge/res, // space between grid "points" r, i; // the representative point int row, col; for (row = 0, i = yLL; row < res; row++, i += gap) for (col = 0, r = xLL; col < res; col++, r += gap) cnt[row][col] = getCount(new Complex(r, i), lim); } // compute the count associated with a complex point final private int getCount(Complex c, int lim) { Complex z = new Complex(c); int count = 1; for (; z.sizeSquared() < 4.0 && count < lim; count++) { z.multiply(z); z.add(c); } return count; } }