blob: c3aa441c9895a396890cb3996203f91f2869d447 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mandelbrot;
/**
*
* @author Sjaak
*/
public class ColorChooser {
private int maxIndex;
public ColorChooser () {
maxIndex = 0;
}
public void setMaxIndex (int max_index) {
maxIndex = max_index;
}
public int getColorIndex (double x0, double y0) {
double x = x0, y = y0;
int color_index = 0;
while (x * x + y * y < 4.0) {
double nx = x * x - y * y + x0;
y = 2 * x * y + y0;
x = nx;
color_index++;
if (color_index == maxIndex) {
return -1;
}
}
return color_index;
}
}
|