st z_im2 = z_im * z_im;
                    if (z_re2 + z_im2 > 4) return n;
                    // z = z^2 + c
                    z_im = 2 * z_re * z_im + c_im;
                    z_re = z_re2 - z_im2 + c_re;
                }
                return MAX_ITER;
            }

            // 绘制单帧
            function drawFrame() {
                const charSize = 8;
                ctx.clearRect(0, 0, width, height);
                const len = chars.length;
                const colorCount = colors