function draw_julia_set(c, canvas, bail = 200) {
let xmin = -2;
let xmax = 2;
let ymin = -2;
let ymax = 2;
let context = canvas.getContext("2d");
let canvasData = context.createImageData(canvas.width, canvas.height);
for (let i = 0; i < canvas.width; i++) {
for (let j = 0; j < canvas.height; j++) {
let xy = canvas_to_xy([i, j], xmin, xmax, ymin, ymax, canvas, bail);
let it_cnt = juliaOrbitCount(c.re, c.im, xy[0], xy[1], bail);
let color = 255 - (255 * it_cnt) / (bail + 1);
let idx = (i + j * canvas.width) * 4;
canvasData.data[idx + 0] = color;
canvasData.data[idx + 1] = color;
canvasData.data[idx + 2] = color;
canvasData.data[idx + 3] = 255;
}
}
context.putImageData(canvasData, 0, 0);
}