14 | 14 |
class Renderer(object):
|
15 | 15 |
"""Takes a source directory filled with text files and a destination directory and
|
16 | 16 |
creates one image file in the destination directory from each text file in the source."""
|
17 | |
def __init__(self, command_template, src, dest, exe, width=320, height=200):
|
18 | |
self.command_template = command_template
|
|
17 |
def __init__(self, config, src, dest, exe):
|
|
18 |
self.command_template = config['command_template']
|
|
19 |
self.libdir = config['libdir']
|
19 | 20 |
self.src = src
|
20 | 21 |
self.dest = dest
|
21 | 22 |
self.exe = exe
|
22 | |
self.width = width
|
23 | |
self.height = height
|
|
23 |
self.width = config['width']
|
|
24 |
self.height = config['height']
|
24 | 25 |
|
25 | 26 |
def render_all(self):
|
26 | 27 |
for filename in sorted(os.listdir(self.src)):
|
|
34 | 35 |
def render(self, frame, full_srcname, full_destname):
|
35 | 36 |
cmd = self.command_template.format(
|
36 | 37 |
infile=full_srcname,
|
37 | |
indir=self.src,
|
|
38 |
libdir=self.libdir,
|
38 | 39 |
outfile=full_destname,
|
39 | 40 |
width=self.width,
|
40 | 41 |
height=self.height
|
|
57 | 58 |
|
58 | 59 |
options = argparser.parse_args(sys.argv[1:])
|
59 | 60 |
|
60 | |
with open(options.configfile, 'r') as file_:
|
61 | |
config = yaml.load(file_, Loader=Loader)
|
|
61 |
config = load_config_file(options.configfile)
|
62 | 62 |
|
63 | |
exe = LoggingExecutor('movie.log')
|
|
63 |
exe = LoggingExecutor('renderer.log')
|
64 | 64 |
|
65 | |
renderer = Renderer(config['command_template'], options.instantsdir, options.framesdir, exe)
|
|
65 |
renderer = Renderer(config, options.instantsdir, options.framesdir, exe)
|
66 | 66 |
renderer.render_all()
|
67 | 67 |
|
68 | 68 |
exe.close()
|