import java.awt.*; class Mandelbrot { private int nb; private Color[] colors; public Mandelbrot(int nb) { int i; float c; float dc = (float) 2.0 / (float) nb; this.nb = nb; colors = new Palette(nb + 1).getColorsArray(); } public Color color(double x, double y) { double x1 = 0.0, y1 = 0.0, x2, y2; for (int i = 0; i < nb; i++) { if (x1 * x1 + y1 * y1 > 4) return colors[i + 1]; x2 = x1 * x1 - y1 * y1 + x; y2 = 2.0 * x1 * y1 + y; x1 = x2; y1 = y2; } return colors[0]; } }