きったんの頭ん中☆
// <applet code="Mondelbrot.class" width="600" height="400"></applet>
/**
* Mondelbrot.java
* @see https://mind.kittttttan.info/java/mandelbrot.html
*/
import java.applet.* ;
import java.awt.* ;
public class Mondelbrot extends Applet {
private static int LOOP = 255;
private static int ZOOM = 200;
private static int WIDTH = ZOOM*3;
private static int HEIGHT = ZOOM*2;
public static int lim(double x, double y) {
int c = 0;
double nx, ny, px = 0, py = 0;
for (int i = 0; i < LOOP; i++) {
nx = px*px - py*py + x;
ny = 2*px*py + y;
if (nx*nx + ny*ny > 4.0) {
c = i+1;
break;
}
px = nx;
py = ny;
}
if (c == 0) {c = LOOP;}
return c;
}
public void paint(Graphics g) {
int t;
for (int i = 0; i < WIDTH; i++) {
for (int j = 0; j < HEIGHT; j++) {
t = lim((double)i/ZOOM - 2.0, (double)j/ZOOM - 1.0);
if (t < LOOP) {
t <<= 4;
if (t > 255) {t = 255;}
g.setColor(new Color(0, 0, t));
} else {
g.setColor(Color.black);
}
g.fillRect(i, j, 1, 1);
}
}
}
}