def makemandel(mandelx, mandely, xbeg, xend, ybeg, yend, filename=None):

    # drawing area (xa < xb and ya < yb)
    xa = -2.0
    xb =  1.0
    ya = -1.5
    yb =  1.5

    # maximum iterations
    maxIt = 128 

    # the output image
    image = Image.new("RGB", (xend-xbeg, yend-ybeg))

    for y in range(ybeg, yend):
        cy = y * (yb - ya) / (mandely - 1)  + ya
        for x in range(xbeg, xend):
            cx = x * (xb - xa) / (mandelx - 1) + xa
            c = complex(cx, cy)
            z = 0
            for i in range(maxIt):
                if abs(z) > 2.0: break 
                z = z * z + c 
            r = i % 4 * 16
            g = i % 6 * 16
            b = i % 16 * 16
            image.putpixel((x-xbeg, y-ybeg), b * 65536 + g * 256 + r)
 
    if filename is not None:
        image.save(filename, "GIF")
    else:
        image.save("mandel_x_%s_%s_y%s_%s.gif" % (xbeg, xend, ybeg, yend), "GIF")
    return image

################################################################################
##
dataset/ETHPy150Open saga-project/BigJob/examples/xsede2013/mandelbrot.py/makemandel/original