from numba import njit
import numpy as np

@njit
def generate_mandelbrot(xmin, xmax, ymin, ymax, width, height, max_iter):
    img = np.zeros((height, width), dtype=np.uint32)
    for i in range(height):
        for j in range(width):
            x0 = xmin + (xmax - xmin) * j / width
            y0 = ymin + (ymax - ymin) * i / height
            x, y = 0.0, 0.0
            iter = 0
            while x*x + y*y <= 4.0 and iter < max_iter:
                xtemp = x*x - y*y + x0
                y = 2*x*y + y0
                x = xtemp
                iter += 1
            img[i, j] = iter
    return img
