def main(): from modules.boids import B from sand import Sand from fn import Fn fn = Fn(prefix='./res/', postfix='.png') sand = Sand(SIZE) sand.set_bg(BACK) sand.set_rgba(FRONT) b = B(INIT_NUM, SIZE, STP) for itt in range(1000000): b.step(separation=SEPARATION, cohesion=COHESION, alignment=ALIGNMENT) xy = b.xy for i, nearby in enumerate(b.get_nearby()): if not nearby: continue start = zeros((len(nearby), 2)) start[:, 0] = xy[i, 0] start[:, 1] = xy[i, 1] stop = xy[nearby, :] g = GRAINS * ones(len(nearby), 'int') sand.paint_strokes(start, stop, g) if not itt % DRAW_ITT: name = fn.name() print(itt, name) sand.write_to_png(name)
def main(): from sand import Sand size = 1000 s = Sand(size) t = time() xya = random((1000000,2)) xyb = random((1000000,2)) s.paint_strokes(xya, xyb, GRAINS, RED) s.write_to_png('./out.png') t1 = time()-t print('time', t1)