.real + this.imag * this.imag);
            }
        }


        function drawMandelbrot() {
            const ctx = canvas.getContext('2d');
            ctx.clearRect(0, 0, width, height);

            for (let x = 0; x < width; x++) {
                for (let y = 0; y < height; y++) {
                    const cX = (x / width - 0.5) * 3 + xOffset;
                    const cY = (y / height - 0.5) * 3 + yOffset;

                    const iterations = mandelbrot(cX, cY);

                    let colorInde