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 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 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(): 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 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)) 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(): 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)