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.2, 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 % 100 == 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) t_stop = time() print_stats(i, t_stop - t_start, DF)
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 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)