xxxxxxxxxx
41
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 z_real = map(x, 0, 599, -1.7, 1.7);
let z_imag = map(y, 0, 599, 1.7, -1.7);
let a = 0.37;
let b = -0.29;
for (
iteration = 1;
iteration <= 100 && 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 == 101) {
stroke(0, 0, 0);
} else {
let fraction = Math.tanh(iteration/100) + (iteration % 3)/10;
let col_1 = color(0,0,150);
let col_2 = color(255,255,255);
stroke(lerpColor(col_2,col_1,fraction));
}
point(x, y);
}
}
}