algo = {
const imageData = ctx.getImageData(0, 0, w, h);
const data = imageData.data;
for (let py = 0; py < imageData.height; py++) {
const y0 = scaleY(py);
for (let px = 0; px < imageData.width; px++) {
const x0 = scaleX(px);
let iteration = 0;
let x = 0;
let y = 0;
while (x*x + y*y <= 2*2 && iteration < maxIteration) {
let xtemp = x*x - y*y + x0;
y = 2*x*y + y0;
x = xtemp;
iteration++;
}
const color = parseRgbString(scaleColor(iteration));
plot(data, px, py, color);
}
}
ctx.putImageData(imageData, 0, 0);
}