def main(): from iutils.render import Animate from differentialLine import DifferentialLine from modules.show import show_closed from modules.show import show_detail from modules.show import show DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) angles = sorted(random(INIT_NUM) * TWOPI) DF.init_circle_segment(MID, MID, INIT_RAD, angles) def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path fn = None ## render outline with marked circles num = DF.np_get_edges_coordinates(np_coords) show_detail(render, np_coords[:num, :], fn) i += 1 return res render = Animate(SIZE, BACK, FRONT, wrap) render.start()
def main(): from iutils.render import Animate from differentialLine import DifferentialLine from modules.helpers import get_exporter # from modules.show import show_closed # from modules.show import show_detail from modules.show import show DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) from fn import Fn fn = Fn(prefix='./res/') exporter = get_exporter( NMAX, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS } ) def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path ## render outline num = DF.np_get_edges_coordinates(np_edges) if not i % 100: show(render,np_edges[:num,:], None, r=1.3*ONE) # render.write_to_png(fn.name()) exporter( DF, fn.name()+'.2obj' ) ## render solid # num = DF.get_sorted_vert_coordinates(np_verts) #show_closed(render,np_verts[:num,:],fn) i += 1 return res render = Animate(SIZE, BACK, FRONT, wrap) render.start()
def main(): from render.render import Animate from differentialLine import DifferentialLine from modules.helpers import get_exporter # from modules.show import show_closed # from modules.show import show_detail from modules.show import show DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) from fn import Fn fn = Fn(prefix='./res/') exporter = get_exporter( NMAX, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS } ) def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path ## render outline num = DF.np_get_edges_coordinates(np_edges) if not i % 100: show(render,np_edges[:num,:], None, r=1.3*ONE) # render.write_to_png(fn.name()) exporter( DF, fn.name()+'.2obj' ) ## render solid # num = DF.get_sorted_vert_coordinates(np_verts) #show_closed(render,np_verts[:num,:],fn) i += 1 return res render = Animate(SIZE, BACK, FRONT, wrap) render.start()
def main(): import gtk from render.render import Animate from differentialLine import DifferentialLine from modules.show import show_closed from modules.show import show_detail from modules.show import show DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path #fn = None if i%2==0: fn = './ani{:04d}.png'.format(i) else: fn = None ## render outline num = DF.np_get_edges_coordinates(np_coords) show(render,np_coords[:num,:],fn,r=1.3*ONE) ## render solid #sorted_vert_coordinates = DF.get_sorted_vert_coordinates() #show_closed(render,sorted_vert_coordinates,fn) ## render outline with marked circles #num = DF.np_get_edges_coordinates(np_coords) #show_detail(render,np_coords[:num,:],fn) i += 1 return res render = Animate(SIZE, BACK, FRONT, wrap) gtk.main()
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, NZ, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) #angles = sorted(random(INIT_NUM)*TWOPI) #DF.init_passive_circle_segment(MID,MID,100*ONE, angles) angles = sorted(random(INIT_NUM)*pi*5/8) xys = [] for a in angles: x = 0.5 + cos(a)*0.01 y = 0.5 + sin(a)*0.01 xys.append((x,y)) DF.init_passive_line_segment(xys) for i in count(): t_start = time() steps(DF,STEPS_ITT) t_stop = time() print_stats(i*STEPS_ITT,t_stop-t_start,DF) fn = './res/collapse_e_{:010d}.png'.format(i*STEPS_ITT) num = DF.np_get_edges_coordinates(np_coords) show(render,np_coords[:num,:],fn,ONE)
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from modules.show import show_closed from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(NINIT)) DF.init_circle_segment(MID,MID,RAD, angles) for i in count(): t_start = time() steps(DF,STEPS_ITT) t_stop = time() print_stats(i*STEPS_ITT,t_stop-t_start,DF) fn = './res/oryx_bb_{:010d}.png'.format(i*STEPS_ITT) edges_coordinates = DF.get_edges_coordinates() show(render,edges_coordinates,fn) fn = './res/oryx_bb_closed_{:010d}.png'.format(i*STEPS_ITT) sorted_vert_coordinates = DF.get_sorted_vert_coordinates() show_closed(render,sorted_vert_coordinates,fn)
def main(): import gtk from render.render import Animate from differentialLine import DifferentialLine from modules.show import show_closed from modules.show import show_detail from modules.show import show DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) angles = sorted(random(INIT_NUM) * TWOPI) DF.init_circle_segment(MID, MID, INIT_RAD, angles) def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path fn = None ## render outline num = DF.np_get_edges_coordinates(np_edges) show(render, np_edges[:num, :], fn, r=1.3 * ONE) ## render solid # num = DF.get_sorted_vert_coordinates(np_verts) #show_closed(render,np_verts[:num,:],fn) i += 1 return res render = Animate(SIZE, BACK, FRONT, wrap) gtk.main()
def main(): from time import time from itertools import count from differentialLine import DifferentialLine from modules.helpers import print_stats from modules.helpers import get_exporter from modules.show import sandstroke from modules.show import show from modules.show import dots DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) exporter = get_exporter(NMAX) orderd_verts = zeros((NMAX, 2), 'double') ## arc # angles = sorted(random(INIT_NUM)*pi*1.5) # xys = [] # for a in angles: # x = 0.5 + cos(a)*0.2 # y = 0.5 + sin(a)*0.2 # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) angles = sorted(random(INIT_NUM) * TWOPI) DF.init_circle_segment(MID, MID, 0.2, angles) for i in count(): t_start = time() DF.optimize_position(STP) spawn_curl(DF, NEARL, 0.016) if i % EXPORT_ITT == 0: exporter( DF, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS, 'prefix': PREFIX }, i, ) t_stop = time() print_stats(i, t_stop - t_start, DF)
def main(): from iutils.render import Animate from differentialLine import DifferentialLine from modules.show import show_closed from modules.show import show_detail from modules.show import show DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path fn = None ## render outline with marked circles num = DF.np_get_edges_coordinates(np_coords) show_detail(render,np_coords[:num,:],fn) i += 1 return res render = Animate(SIZE, BACK, FRONT, wrap) render.start()
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from modules.show import show_closed from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(NINIT)*TWOPI) DF.init_circle_segment(MID,MID,RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) spawn_curl(DF,NEARL) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: fn = './res/oryx_bb_{:010d}.png'.format(i) num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],fn) fn = './res/oryx_bb_closed_{:010d}.png'.format(i) num = DF.np_get_sorted_vert_coordinates(np_verts) show_closed(render,np_verts[:num,:],fn)
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from modules.show import show_closed from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(NINIT)) DF.init_circle_segment(MID, MID, RAD, angles) for i in count(): t_start = time() steps(DF, STEPS_ITT) t_stop = time() print_stats(i * STEPS_ITT, t_stop - t_start, DF) fn = './res/oryx_bb_{:010d}.png'.format(i * STEPS_ITT) edges_coordinates = DF.get_edges_coordinates() show(render, edges_coordinates, fn) fn = './res/oryx_bb_closed_{:010d}.png'.format(i * STEPS_ITT) sorted_vert_coordinates = DF.get_sorted_vert_coordinates() show_closed(render, sorted_vert_coordinates, fn)
def main(): import gtk from render.render import Animate from differentialLine import DifferentialLine from modules.show import sandstroke from modules.show import dots from modules.show import show DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) ## arc #angles = sorted(random(INIT_NUM)*pi*1.5) #xys = [] #for a in angles: #x = 0.5 + cos(a)*0.06 #y = 0.5 + sin(a)*0.06 #xys.append((x,y)) #DF.init_line_segment(xys, lock_edges=1) ## vertical line #xx = sorted(0.45+0.1*random(INIT_NUM)) #yy = MID+0.005*(0.5-random(INIT_NUM)) #xys = [] #for x,y in zip(xx,yy): #xys.append((x,y)) #DF.init_line_segment(xys, lock_edges=1) # diagonal line yy = sorted(0.3+0.4*random(INIT_NUM)) xx = 0.3+linspace(0,0.4,num=INIT_NUM) xys = [] for x,y in zip(xx,yy): xys.append((x,y)) DF.init_line_segment(xys, lock_edges=1) #angles = sorted(random(INIT_NUM)*TWOPI) #DF.init_circle_segment(MID,MID,FARL*0.2, angles) def wrap(render): global i global np_coords global np_vert_coords ## if fn is a path each image will be saved to that path #fn = './res/ani{:04d}.png'.format(i) fn = None res = steps(DF) render.set_front(FRONT) coord_num = DF.np_get_edges_coordinates(np_coords) sandstroke(render,np_coords[:coord_num,:],10,fn) #vert_num = DF.np_get_vert_coordinates(np_vert_coords) #dots(render,np_vert_coords[:vert_num,:],fn) i += 1 return res render = Animate(SIZE, BACK, FRONT, wrap) gtk.main()
def main(): from time import time from itertools import count from iutils.render import Render from modules.helpers import print_stats from modules.show import show # from modules.show import show_closed from differentialLine import DifferentialLine from modules.helpers import get_exporter from numpy.random import random from fn import Fn DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) fn = Fn(prefix='./res/') exporter = get_exporter( NMAX, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS } ) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) # spawn_curl(DF,NEARL) spawn(DF, NEARL, 0.03) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: name = fn.name() num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],name+'.png') exporter( DF, name+'.2obj' )
def main(): from time import time from itertools import count from differentialLine import DifferentialLine from render.render import Render from modules.helpers import print_stats from modules.show import sandstroke from modules.show import show from modules.show import dots np_coords = zeros(shape=(NMAX, 4), dtype='float') np_vert_coords = zeros(shape=(NMAX, 2), dtype='float') DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) ## arc #angles = sorted(random(INIT_NUM)*pi*1.5) #xys = [] #for a in angles: #x = 0.5 + cos(a)*0.2 #y = 0.5 + sin(a)*0.2 #xys.append((x,y)) ## vertical line #yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) #xx = MID+0.005*(0.5-random(INIT_NUM)) #xys = [] #for x,y in zip(xx,yy): #xys.append((x,y)) #DF.init_line_segment(xys, lock_edges=1) ## diagonal line yy = sorted(MID + 0.2 * (1 - 2 * random(INIT_NUM))) xx = sorted(MID + 0.2 * (1 - 2 * random(INIT_NUM))) xys = [] for x, y in zip(xx, yy): xys.append((x, y)) DF.init_line_segment(xys, lock_edges=1) for i in count(): t_start = time() DF.optimize_avoid(STP) spawn_curl(DF, NEARL) if i % 100 == 0: fn = './res/line_expand_ab_{:04d}.png'.format(i) else: fn = None render.set_front(FRONT) num = DF.np_get_edges_coordinates(np_coords) sandstroke(render, np_coords[:num, :], 20, fn) if i % 40 == 0: render.set_front([0, 0, 0, 0.3]) num = DF.np_get_edges_coordinates(np_coords) sandstroke(render, np_coords[:num, :], 10, fn) t_stop = time() print_stats(i, t_stop - t_start, DF)
def main(): from time import time from itertools import count from differentialLine import DifferentialLine from iutils.render import Render from modules.helpers import print_stats from modules.show import sandstroke from modules.show import show from modules.show import dots np_coords = zeros(shape=(NMAX, 4), dtype='float') np_vert_coords = zeros(shape=(NMAX, 2), dtype='float') DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(INIT_NUM) * TWOPI) DF.init_circle_segment(MID, MID, 0.025, angles) # arc # angles = sorted(random(INIT_NUM)*pi*1.5) # xys = [] # for a in angles: # x = 0.5 + cos(a)*0.2 # y = 0.5 + sin(a)*0.2 # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) # vertical line # yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xx = MID+0.005*(0.5-random(INIT_NUM)) # xys = [] # for x, y in zip(xx, yy): # xys.append((x, y)) # DF.init_line_segment(xys, lock_edges=1) # diagonal line # yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xx = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xys = [] # for x, y in zip(xx, yy): # xys.append((x, y)) # DF.init_line_segment(xys, lock_edges=1) for i in count(): t_start = time() DF.optimize_position(STP) spawn_curl(DF, NEARL, 0.016) if i % 500 == 0: fn = './res/chris_bd_{:04d}.png'.format(i) else: fn = None render.set_front(FRONT) num = DF.np_get_edges_coordinates(np_coords) #sandstroke(render, np_coords[:num, :], 20, fn) if random() < 0.05: sandstroke(render, np_coords[:num, :], 30, None) vert_num = DF.np_get_vert_coordinates(np_vert_coords) #dots(render, np_vert_coords[:vert_num, :], None) dots(render, np_vert_coords[:vert_num, :], fn) t_stop = time() print_stats(i, t_stop - t_start, DF)
def main(): import gtk from time import time from render.render import Animate from modules.helpers import print_stats from differentialLine import DifferentialLine from modules.show import show_closed from modules.show import show_detail from modules.show import show DF = DifferentialLine(NMAX, NZ, NEARL, FARL, PROCS) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) def steps(df): global i df.optimize_avoid(STP) spawn_curl(df, NEARL) def wrap(steps_itt, render): global i t1 = time() steps(DF) fn = None #edges_coordinates = DF.get_edges_coordinates() #sorted_vert_coordinates = DF.get_sorted_vert_coordinates() #fn = './res/ani{:04d}.png'.format(i) #show_detail(render,edges_coordinates,sorted_vert_coordinates,fn) edges_coordinates = DF.get_edges_coordinates() fn = './res/ani{:04d}.png'.format(i) show(render,edges_coordinates,fn) #sorted_vert_coordinates = DF.get_sorted_vert_coordinates() #fn = './res/ani{:04d}.png'.format(i) #show_closed(render,sorted_vert_coordinates,fn) t2 = time() print_stats(render.steps, t2-t1, DF) i += 1 return True render = Animate(SIZE, BACK, FRONT, None, wrap) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) gtk.main()
def main(): from time import time from itertools import count from numpy import pi from numpy.random import random from modules.growth import spawn_curl from modules.utils import get_exporter from modules.helpers import env_or_default from modules.helpers import print_stats from differentialLine import DifferentialLine comm = MPI.COMM_WORLD nodes = comm.Get_size() rank = comm.Get_rank() if rank == 0: size = env_or_default('SIZE', SIZE) nmax = env_or_default('NMAX', NMAX) one = 1.0/size export_itt = env_or_default('EXPORT_ITT', EXPORT_ITT) stat_itt = env_or_default('STAT_ITT', STAT_ITT) data = { 'size': size, 'nmax': nmax, 'vmax': env_or_default('VMAX', NMAX), 'procs': env_or_default('PROCS', PROCS), 'nodes': nodes, 'prefix': env_or_default('PREFIX', PREFIX), 'ninit': env_or_default('NINIT', NINIT), 'rad': env_or_default('RAD', RAD), 'one': one, 'stp': env_or_default('STP', STP)*one, 'nearl': env_or_default('NEARL', NEARL)*one, 'farl': env_or_default('FARL', FARL)*one } else: data = None data = comm.bcast(data, root=0) DF = DifferentialLine( data['nmax'], zonewidth = data['farl'], nearl = data['nearl'], farl = data['farl'], procs = data['procs'], nodes = data['nodes'] ) if rank == 0: angles = sorted(random(data['ninit'])*pi*2) DF.init_circle_segment(0.5, 0.5, data['rad'], angles) t_start = time() do_export = get_exporter(nmax, t_start) for i in count(): DF.optimize_position(data['stp']) if DF.get_vnum()>data['vmax']: if rank == 0: do_export(DF, data, i, final=True) return if rank == 0: spawn_curl(DF,data['nearl']) if i % stat_itt == 0: print_stats(i,time()-t_start,DF) if i % export_itt == 0: do_export(DF, data, i)
def main(): import gtk from time import time from render.render import Animate from modules.helpers import print_stats from differentialLine import DifferentialLine from math import ceil from modules.show import show_closed from modules.show import show_detail from modules.show import show from modules.show import sandstroke from modules.growth import collapse DF = DifferentialLine(NMAX, NZ, NEARL, FARL, PROCS) #angles = sorted(random(INIT_NUM)*TWOPI) #DF.init_passive_circle_segment(MID,MID,0.1, angles) angles = sorted(random(INIT_NUM)*pi*5/8) xys = [] for a in angles: x = 0.5 + cos(a)*0.05 y = 0.5 + sin(a)*0.1 xys.append((x,y)) DF.init_passive_line_segment(xys) # TODO: # add better proximity func def steps(df): global i active_num = df.get_active_vertex_count() print(active_num) if active_num<3: rad = df.get_greatest_distance(MID,MID) + FREEZE_DISTANCE*3 circ = rad*4*3.14 nodes = ceil(circ/NEARL) print(rad, nodes) angles = sorted(random(nodes)*TWOPI) df.init_circle_segment(MID,MID, rad, angles) collapse(df, NEARL, 0.1) df.split_long_edges(NEARL*2.5) df.optimize_contract(STP, FREEZE_DISTANCE) def wrap(steps_itt, render): global i global np_coords t1 = time() steps(DF)# if i%3 == 0: fn = './res/ani{:04d}.png'.format(i) else: fn = None num = DF.np_get_edges_coordinates(np_coords) show(render,np_coords[:num,:],fn,ONE) #sandstroke(render,np_coords[:num,:],8,None) t2 = time() print_stats(render.steps, t2-t1, DF) i += 1 return True render = Animate(SIZE, BACK, FRONT, None, wrap) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) gtk.main()
def main(): from time import time from itertools import count from differentialLine import DifferentialLine from modules.helpers import print_stats from modules.helpers import get_exporter from modules.show import sandstroke from modules.show import show from modules.show import dots DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) exporter = get_exporter(NMAX) orderd_verts = zeros((NMAX,2), 'double') ## arc # angles = sorted(random(INIT_NUM)*pi*1.5) # xys = [] # for a in angles: # x = 0.5 + cos(a)*0.2 # y = 0.5 + sin(a)*0.2 # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,0.2, angles) for i in count(): t_start = time() DF.optimize_position(STP) spawn_curl(DF,NEARL,0.016) if i % EXPORT_ITT == 0: exporter( DF, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS, 'prefix': PREFIX }, i, ) t_stop = time() print_stats(i,t_stop-t_start,DF)
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show # from modules.show import show_closed from differentialLine import DifferentialLine from modules.helpers import get_exporter from numpy.random import random from fn import Fn DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) fn = Fn(prefix='./res/') exporter = get_exporter( NMAX, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS } ) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) # spawn_curl(DF,NEARL) spawn(DF, NEARL, 0.03) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: name = fn.name() num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],name+'.png') exporter( DF, name+'.2obj' )
def main(): from iutils.render import Animate from differentialLine import DifferentialLine from fn import Fn from modules.show import sandstroke from modules.show import dots DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) ## arc # angles = sorted(random(INIT_NUM)*pi*1.5) # xys = [] # for a in angles: # x = 0.5 + cos(a)*0.06 # y = 0.5 + sin(a)*0.06 # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) ## vertical line #xx = sorted(0.45+0.1*random(INIT_NUM)) #yy = MID+0.005*(0.5-random(INIT_NUM)) #xys = [] #for x,y in zip(xx,yy): #xys.append((x,y)) #DF.init_line_segment(xys, lock_edges=1) # diagonal line # yy = sorted(0.3+0.4*random(INIT_NUM)) # xx = 0.3+linspace(0,0.4,num=INIT_NUM) # xys = [] # for x,y in zip(xx,yy): # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,FARL*0.2, angles) fn = Fn(prefix='./res/', postfix='.png') def wrap(render): global np_coords global np_vert_coords global grains ## if fn is a path each image will be saved to that path if not render.steps%3: f = fn.name() else: f = None grains += (-1)**floor(2*random()) print(grains) if grains<0: grains = 0 res = steps(DF) render.set_front(FRONT) coord_num = DF.np_get_edges_coordinates(np_coords) sandstroke(render,np_coords[:coord_num,:],grains,f) if not random()<0.1: vert_num = DF.np_get_vert_coordinates(np_vert_coords) dots(render,np_vert_coords[:vert_num,:],None) return res render = Animate(SIZE, BACK, FRONT, wrap) render.start()
def main(): from iutils.render import Animate from differentialLine import DifferentialLine from fn import Fn from modules.show import sandstroke from modules.show import dots DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) ## arc # angles = sorted(random(INIT_NUM)*pi*1.5) # xys = [] # for a in angles: # x = 0.5 + cos(a)*0.06 # y = 0.5 + sin(a)*0.06 # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) ## vertical line #xx = sorted(0.45+0.1*random(INIT_NUM)) #yy = MID+0.005*(0.5-random(INIT_NUM)) #xys = [] #for x,y in zip(xx,yy): #xys.append((x,y)) #DF.init_line_segment(xys, lock_edges=1) # diagonal line # yy = sorted(0.3+0.4*random(INIT_NUM)) # xx = 0.3+linspace(0,0.4,num=INIT_NUM) # xys = [] # for x,y in zip(xx,yy): # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) angles = sorted(random(INIT_NUM) * TWOPI) DF.init_circle_segment(MID, MID, FARL * 0.2, angles) fn = Fn(prefix='./res/', postfix='.png') def wrap(render): global np_coords global np_vert_coords global grains ## if fn is a path each image will be saved to that path if not render.steps % 3: f = fn.name() else: f = None grains += (-1)**floor(2 * random()) print(grains) if grains < 0: grains = 0 res = steps(DF) render.set_front(FRONT) coord_num = DF.np_get_edges_coordinates(np_coords) sandstroke(render, np_coords[:coord_num, :], grains, f) if not random() < 0.1: vert_num = DF.np_get_vert_coordinates(np_vert_coords) dots(render, np_vert_coords[:vert_num, :], None) return res render = Animate(SIZE, BACK, FRONT, wrap) render.start()
def main(): from time import time from itertools import count from differentialLine import DifferentialLine from render.render import Render from modules.helpers import print_stats from modules.show import sandstroke from modules.show import show from modules.show import dots np_coords = zeros(shape=(NMAX,4), dtype='float') np_vert_coords = zeros(shape=(NMAX,2), dtype='float') DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) ## arc angles = sorted(random(INIT_NUM)*pi*1.5) xys = [] for a in angles: x = 0.5 + cos(a)*0.2 y = 0.5 + sin(a)*0.2 xys.append((x,y)) DF.init_line_segment(xys, lock_edges=1) ## vertical line #yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) #xx = MID+0.005*(0.5-random(INIT_NUM)) #xys = [] #for x,y in zip(xx,yy): #xys.append((x,y)) #DF.init_line_segment(xys, lock_edges=1) ## diagonal line # yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xx = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xys = [] # for x,y in zip(xx,yy): # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) for i in count(): t_start = time() DF.optimize_position(STP) spawn_curl(DF,NEARL,0.016) if i%100==0: fn = './res/sider_arc_ac_{:04d}.png'.format(i) else: fn = None render.set_front(FRONT) num = DF.np_get_edges_coordinates(np_coords) sandstroke(render,np_coords[:num,:],20,fn) if random()<0.05: sandstroke(render,np_coords[:num,:],30,None) vert_num = DF.np_get_vert_coordinates(np_vert_coords) dots(render,np_vert_coords[:vert_num,:],None) t_stop = time() print_stats(i,t_stop-t_start,DF)
def main(): import gtk from time import time from render.render import Animate from modules.helpers import print_stats from differentialLine import DifferentialLine from modules.show import sandstroke from modules.show import dots from modules.show import show DF = DifferentialLine(NMAX, NZ, NEARL, FARL, PROCS) ## arc #angles = sorted(random(INIT_NUM)*pi*1.5) #xys = [] #for a in angles: #x = 0.5 + cos(a)*0.06 #y = 0.5 + sin(a)*0.06 #xys.append((x,y)) ## vertical line #xx = sorted(0.45+0.1*random(INIT_NUM)) #yy = MID+0.005*(0.5-random(INIT_NUM)) #xys = [] #for x,y in zip(xx,yy): #xys.append((x,y)) ## diagonal line #yy = sorted(0.2+0.6*random(INIT_NUM)) #xx = 0.2+linspace(0,0.6,num=INIT_NUM) #xys = [] #for x,y in zip(xx,yy): #xys.append((x,y)) #DF.init_line_segment(xys, lock_edges=1) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,FARL*0.2, angles) def steps(df): global i df.optimize_avoid(STP) spawn_curl(df, NEARL) def wrap(steps_itt, render): global i global np_coords global np_vert_coords fn = None t1 = time() steps(DF) #coord_num = DF.np_get_edges_coordinates(np_coords) ##fn = './res/ani{:04d}.png'.format(i) #sandstroke(render,np_coords[:coord_num,:],10,fn) #if i%2==0: #fn = './res/ani{:04d}.png'.format(i) #else: #fn=None render.set_front(FRONT) vert_num = DF.np_get_vert_coordinates(np_vert_coords) dots(render,np_vert_coords[:vert_num,:],fn) #render.set_front([0,0.8,0.8,0.05]) #coord_num = DF.np_get_edges_coordinates(np_coords) #sandstroke(render,np_coords[:coord_num,:],8,None) #coord_num = DF.np_get_edges_coordinates(np_coords) #show(render,np_coords[:coord_num,:],clear=True) if i%10==0: coord_num = DF.np_get_edges_coordinates(np_coords) sandstroke(render,np_coords[:coord_num,:],8,None) t2 = time() print_stats(render.steps, t2-t1, DF) i += 1 return True render = Animate(SIZE, BACK, FRONT, None, wrap) gtk.main()