xxxxxxxxxx
38
let iteration;
function setup() {
createCanvas(600, 600);
background(245);
noLoop();
}
function draw() {
for (let x = 0; x < 600; x++) {
for (let y = 0; y < 600; y++) {
let a = map(x, 0, 599, -1.5, -0.5);
let b = map(y, 0, 599, -0.5, 0.5);
let z_real = 0;
let z_imag = 0;
for (
iteration = 1;
iteration <= 50 && dist(0, 0, z_real, z_imag) < 2;
iteration++
) {
let z_real_temp = z_real * z_real - z_imag * z_imag + a;
let z_imag_temp = 2 * z_real * z_imag + b;
z_real = z_real_temp;
z_imag = z_imag_temp;
}
if (iteration == 51) {
stroke(0, 0, 0);
} else {
stroke(10 * iteration, 0, 0);
}
point(x, y);
}
}
}