for y_j in y_ints:
            test = True

            x_list = range(int(x_i.a - .5), int(x_i.b + 1.5))
            y_list = range(int(y_j.a - .5), int(y_j.b + 1.5))
            if len(x_list) == 1: x_list.append(1 + x_list[0])
            if len(y_list) == 1: y_list.append(1 + y_list[0])

            x = int(random.choice(x_list))
            y = int(random.choice(y_list))
            x_list.remove(x)
            y_list.remove(y)
            x2 = int(random.choice(x_list))
            y2 = int(random.choice(y_list))

            scott.set_rect(min(x, x2), min(y, y2), abs(x2 - x), abs(y2 - y))

    #uv_imgs = export_uv(scott)

    t1 = time()
    print "performing " + str(gen) + " generations ",
    for n in range(gen):
        print ".",
        scott.step()
        if gen % stepsize == 0:
            scott.record()
    print
    t2 = time()
    print " took: %f" % (t2 - t1)

    print "writing uv images ",
Example #2
0
height = 20
diffusion = GrayScott(Interval(width,height))

'''
for x in range(width):
    for y in range(height):
        if random.uniform(0,1) > 0.75:
            diffusion.set_u(x,y,0.5)
            diffusion.set_v(x,y,0.25)
'''
'''
for r in range(4):
    diffusion.set_rect(random.uniform(10,width-10),random.uniform(10,height-10),random.uniform(2,8),random.uniform(2,8))
'''

diffusion.set_rect(3,10,2,8)
diffusion.set_rect(width-3,height-10,2,8)
diffusion.set_rect(width/2,2,4,4)

from time import time
for n in range(20):
    print "step",n
    t0 = time()
    for m in range(10): diffusion.step()
    diffusion.record()
    print 'step took: %f' %(time()-t0)

n = 0
for img in diffusion.to_image_sequence():
    img.save("img_"+str(n), path, True)
    n+=1
Example #3
0
width = 20
height = 20
diffusion = GrayScott(Interval(width, height))
'''
for x in range(width):
    for y in range(height):
        if random.uniform(0,1) > 0.75:
            diffusion.set_u(x,y,0.5)
            diffusion.set_v(x,y,0.25)
'''
'''
for r in range(4):
    diffusion.set_rect(random.uniform(10,width-10),random.uniform(10,height-10),random.uniform(2,8),random.uniform(2,8))
'''

diffusion.set_rect(3, 10, 2, 8)
diffusion.set_rect(width - 3, height - 10, 2, 8)
diffusion.set_rect(width / 2, 2, 4, 4)

from time import time
for n in range(20):
    print "step", n
    t0 = time()
    for m in range(10):
        diffusion.step()
    diffusion.record()
    print 'step took: %f' % (time() - t0)

n = 0
for img in diffusion.to_image_sequence():
    img.save("img_" + str(n), path, True)
Example #4
0
        img_v._pixels[px] = c

    imgs.append(img_v)

    return imgs


# define corner colors for double interpolation
u0v0 = Color(1, 1, 1)
u0v1 = Color(0, 0, 0)
u1v0 = Color(1, 1, 1)
u1v1 = Color(1, 0, 0)

scott = GrayScott(Interval(100, 100))
'''
scott.set_rect(3,3,3,3)
scott.set_rect(13,13,3,2)
scott.set_rect(18,4,3,8)
'''
scott.set_rect(60, 60, 60, 60)
scott.set_rect(65, 65, 15, 10)
scott.set_rect(90, 20, 15, 40)
scott.record()
#scott.log_uv()

#uv_imgs = export_uv(scott)

gen = 50
stepsize = 5
t1 = time()
        for y_j in y_ints:
            test = True

            x_list = range(int(x_i.a-.5), int(x_i.b+1.5))
            y_list = range(int(y_j.a-.5), int(y_j.b+1.5))
            if len(x_list) == 1: x_list.append(1+x_list[0])
            if len(y_list) == 1: y_list.append(1+y_list[0])

            x = int(random.choice(x_list))
            y = int(random.choice(y_list))
            x_list.remove(x)
            y_list.remove(y)
            x2 = int(random.choice(x_list))
            y2 = int(random.choice(y_list))

            scott.set_rect(min(x,x2),min(y,y2),abs(x2-x),abs(y2-y))



    #uv_imgs = export_uv(scott)

    t1 = time()
    print "performing "+str(gen)+" generations ",
    for n in range(gen):
        print ".",
        scott.step()
        if gen%stepsize == 0:
            scott.record()
    print
    t2 = time()
    print " took: %f" %(t2-t1)
Example #6
0
    imgs.append(img_v)


    return imgs


# define corner colors for double interpolation
u0v0 = Color(1,1,1)
u0v1= Color(0,0,0)
u1v0 = Color(1,1,1)
u1v1 = Color(1,0,0)



scott = GrayScott(Interval(100,100))
'''
scott.set_rect(3,3,3,3)
scott.set_rect(13,13,3,2)
scott.set_rect(18,4,3,8)
'''
scott.set_rect(60,60,60,60)
scott.set_rect(65,65,15,10)
scott.set_rect(90,20,15,40)
scott.record()
#scott.log_uv()

#uv_imgs = export_uv(scott)


gen = 50
stepsize = 5