def blend(self, args): # TODO: check for canonicity of edges lname, lpath, lrev, m = self.flock.find_edge(args.left) rname, rpath, rrev, m = self.flock.find_edge(args.right) name = '%s=%s' % (lname, rname) l, r = [genome.Genome(json.load(open(p))) for p in (lpath, rpath)] try: bl = blend.blend_genomes(l, r, nloops=args.nloops, align=args.align, stagger=args.stagger, blur=args.blur) except: print '\nWhile blending %s and %s:' % (lname, rname) traceback.print_exc() # TODO: propagate? nah, don't think so sys.exit('Error creating %s' % name) bl['link'] = {'left': lname, 'right': rname} return name, min(lrev, rrev)[1], genome.json_encode_genome(bl)
def cvt(name, flame, arc=-360, offset=0, link={'left': 'loop', 'right': 'loop'}): path = os.path.join('edges/reference', name + '.json') gnm = genome.convert_flame(flame, arc, offset) gnm['link'] = link if args.flip and 'final' in gnm['xforms']: a = gnm['xforms']['final']['affine'] a['spread'] = abs(a['spread']) out = genome.json_encode_genome(gnm) with open(path, 'w') as fp: fp.write(out.lstrip()) if args.add: self._git_add(path) print path
def cvt(name, flame, arc=-360, offset=0, link={ 'left': 'loop', 'right': 'loop' }): path = os.path.join('edges/reference', name + '.json') gnm = genome.convert_flame(flame, arc, offset) gnm['link'] = link if args.flip and 'final' in gnm['xforms']: a = gnm['xforms']['final']['affine'] a['spread'] = abs(a['spread']) out = genome.json_encode_genome(gnm) with open(path, 'w') as fp: fp.write(out.lstrip()) if args.add: self._git_add(path) print path
import sys, json sys.path.insert(0, '.') from cuburn.genome import Genome, json_encode_genome with open(sys.argv[1]) as fp: gnm = Genome(json.load(fp)) gnm['xforms'].pop('final', False) n = len(gnm['xforms']) for i, v in enumerate(gnm['xforms'].values()): v['variations'] = {'linear':{'weight':1}} o = 0.002 * i / n csp, cv = v['color_speed'], v['color'] v['affine'] = { 'angle': 45, 'spread': 45, 'magnitude': {'x': 0.001, 'y': [0, 1-csp(0), 1, 1-csp(1)]}, 'offset': {'x': [0, o - 8./9, 1, o + 8./9], 'y': [0, cv(0)*csp(0), 1, cv(1)*csp(1)]} } v.pop('post', False) gnm['color']['highlight_power'] = 0 gnm['camera'].update(center={'x': 0,'y':-0.5}, rotation=0, scale=9. / 16, filter_width=2) name = sys.argv[1].rsplit('.', 1)[0] + '.showpal.json' with open(name, 'w') as fp: fp.write(json_encode_genome(gnm)) print 'okay, now run:' print 'python main.py --duration 0.5 --fps 1 -p 720p %s' % name