xxxxxxxxxx
43
const max_iteration = 100;
function setup() {
createCanvas(600, 600);
colorMode(HSB);
for(let i = 0; i < width; i ++) {
for(let j = 0; j < height; j ++) {
let n = iterations(i, j);
stroke(((n/max_iteration) * 255), 255, 255);
point(i, j);
}
}
noLoop();
}
function draw() {
// background(220);
}
function iterations(px, py) {
let x0 = map(px, 0, width, -2.00, 0.47);
let y0 = map(py, 0, height, -1.12, 1.12);
let x = 0;
let y = 0;
for(let i = 0; i < max_iteration; i ++) {
if(x*x + y*y > 2*2) {
return i;
}
let xtemp = x*x - y*y + x0
y = 2*x*y + y0
x = xtemp
}
return max_iteration;
}