Commit 39bb861a authored by Lucas Bourneuf's avatar Lucas Bourneuf

improve API

parent 519678c4
......@@ -4,6 +4,7 @@ Call example in main.
import os
import io
import time
import json
import clyngor
......@@ -31,13 +32,14 @@ def single_image_from_filenames(fnames:[str], outfile:str=None, dotfile:str=None
return compile_to_single_image(final_context, outfile=outfile, dotfile=dotfile, return_image=return_image, verbosity=verbosity)
def gif_from_filenames(fnames:[str], giffile:str, dotfile_template:str=None, duration:int=1000, verbosity:int=0) -> str:
def gif_from_filenames(fnames:[str], giffile:str=None, dotfile_template:str=None, duration:int=1000, verbosity:int=0) -> bytes or str:
"""Make a gif, with each ASP model as an image. Save it in outfile and dotfile_template"""
pipeline = build_pipeline(fnames, verbosity)
final_context = run(pipeline, verbosity=verbosity)
first, *lasts = compile_to_images(final_context, dotfile_template=dotfile_template, return_image=True, verbosity=verbosity), save_all=True, append_images=lasts, duration=duration, loop=0)
return giffile
output = io.BytesIO() if giffile is None else giffile, save_all=True, append_images=lasts, duration=duration, loop=0)
return output.getvalue() if giffile is None else giffile
def build_pipeline(fnames:[str], verbosity:int=0) -> [Script]:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment