def mandelbrot(xint, yint, size, maxreps): width, height = size img = ImagePPM.new(size) for i in range(width): for j in range(height): a = lerp(i / width, xint[0], xint[1]) b = lerp(1 - j / height, yint[0], yint[1]) c = complex(a, b) img.putpixel((i, j), testpoint(c, maxreps)) return img