Пример #1
0
def smart_zoom(fractal, maxiter, data, pool=3, resx=256, resy=256):
    subdata = sub(data)
    dif_list = np.empty(16, dtype=object)
    for i, x in enumerate(subdata):
        dif_list[i] = diff(x, maxiter)

    print(dif_list)
    """Gives index table"""
    k = sorted(range(len(dif_list)), key=lambda x: dif_list[x])
    val = k[len(k) - 1 - random.randint(0, pool - 1)]
    print(str(k) + " chose val: " + str(val))
    """val, value=max(enumerate(dif_list), key=operator.itemgetter(1))	"""

    value = dif_list[val]
    """x=, y=0..3"""
    x = (val) % 4
    y = (val - x) / 4

    print("Interesting x: " + str(x))
    print("Interesting y: " + str(y))
    print(fractal.w)

    fractal_rec = fractal5.mandelbrot()

    fractal_rec.x = fractal.x + Decimal((-3.0 + 2.0 * x) / 8.0) * fractal.w
    fractal_rec.y = fractal.y + Decimal((-3.0 + 2.0 * y) / 8.0) * fractal.h
    fractal_rec.w = fractal.w / Decimal(4.0)
    fractal_rec.h = fractal.h / Decimal(4.0)

    print("x: " + str(fractal_rec.x))
    print("y: " + str(fractal_rec.y))
    print("w: " + str(fractal_rec.w))

    return fractal_rec
Пример #2
0
def rand_zoom(fractal,
              maxiter,
              data,
              pool=3,
              subx=8.0,
              suby=16.0,
              resx=256,
              resy=256):
    subdata = sub(data, incc=subx, incr=suby)
    dif_list = []

    nonNullData = []

    for i, data in enumerate(subdata):
        if np.var(data) >= 0.1:
            nonNullData.append({"data": data, "indexVal": i})

    val = nonNullData[random.randint(0, len(nonNullData))]["indexVal"]
    """Finds x and y"""
    x = (val) % subx
    y = (val - x) / subx
    """print("x: "+str(x)+"; y: "+str(y))"""

    fractal_rec = fractal5.mandelbrot()
    fractal_rec.x = fractal.x + Decimal(
        (-(subx - 1) + 2.0 * x) / (subx * 2)) * fractal.w
    fractal_rec.y = fractal.y + Decimal(
        (-(suby - 1) + 2.0 * y) / (suby * 2)) * fractal.h
    fractal_rec.w = fractal.w / Decimal(4)
    fractal_rec.h = fractal.h / Decimal(4)

    return fractal_rec
Пример #3
0
def mask_zoom(fractal,
              maxiter,
              data,
              pool=3,
              subx=8.0,
              suby=16.0,
              resx=256,
              resy=256):

    subdata = sub(data, incc=subx, incr=suby)
    dif_list = np.empty(int(subx * suby), dtype=object)

    mask = mask_hill(int(resx / subx), int(resy / suby), maxiter)
    """print(subdata[0].shape);	
	print(mask.shape);"""

    for i, x in enumerate(subdata):
        dif_list[i] = mask_fit(x, mask)
    """print(dif_list)"""
    """Gives index table"""
    k = sorted(range(len(dif_list)), key=lambda x: dif_list[x])
    val = k[len(k) - 1 - random.randint(0, pool - 1)]
    """print(str(k) + " chose val: "+str(val))"""

    value = dif_list[val]
    """Finds x and y"""
    x = (val) % subx
    y = (val - x) / subx
    """print("x: "+str(x)+"; y: "+str(y))"""

    fractal_rec = fractal5.mandelbrot()
    fractal_rec.x = fractal.x + Decimal(
        (-(subx - 1) + 2.0 * x) / (subx * 2)) * fractal.w
    fractal_rec.y = fractal.y + Decimal(
        (-(suby - 1) + 2.0 * y) / (suby * 2)) * fractal.h
    fractal_rec.w = fractal.w / Decimal(4)
    fractal_rec.h = fractal.h / Decimal(4)

    return fractal_rec
Пример #4
0
	fractal_rec.y=fractal.y+Decimal((-3.0+2.0*y)/8.0) * fractal.h
	fractal_rec.w=fractal.w/Decimal(4.0)
	fractal_rec.h=fractal.h/Decimal(4.0)
	
	print("x: "+str(fractal_rec.x))
	print("y: "+str(fractal_rec.y))
	print("w: "+str(fractal_rec.w))

	return fractal_rec
	
if __name__=="__main__":

	print("How many threads to use?")
	i_threads=int(input())	

	a=fractal5.mandelbrot()
	a.x=a.x
	a.y=a.y
	a.w=Decimal(8.0)
	a.h=Decimal(16.0)
	getcontext().prec=6
	for i in range(1,2048):
		dbx=str(a.x)
		dby=str(a.y)
		dbw=str(a.w)
		dbh=str(a.h)

		r=a.render(i*80,resx=108*2,resy=216*2,threadCount=i_threads)
		a=smart_zoom(a,i*80*1000,(r*10000).astype(int),resx=108*2,resy=216*2)

		sn=sinemap(r,randOFF(),2,randOFF(),3,randOFF(),4)