def make_rst(anim, file_name='anim.rst', fps=None, embed_frames=True, default_mode='once'): """ Take an animation created by make_anim and convert it into an rst file (reStructuredText, for inclusion in Sphinx documentation, for example). """ from JSAnimation.IPython_display import anim_to_html rst_body = anim_to_html(anim, fps=fps, embed_frames=embed_frames, \ default_mode=default_mode) rst_body = rst_body.split('\n') rst_file = open(file_name, 'w') rst_file.write(".. raw:: html\n") for line in rst_body: rst_file.write(" %s\n" % line) rst_file.close() print("Created %s" % file_name) print("Imbed this in another rst file using:") print(".. include:: %s" % file_name)
def make_html(anim, file_name='anim.html', title=None, raw_html='', \ fps=None, embed_frames=True, default_mode='once'): """ Take an animation created by make_anim and convert it into a stand-alone html file. """ try: from JSAnimation.IPython_display import anim_to_html except: try: from clawpack.visclaw.JSAnimation.IPython_display import anim_to_html except: print( "*** Warning: JSAnimation not found, cannot import anim_to_html" ) html_body = anim_to_html(anim, fps=fps, embed_frames=embed_frames, \ default_mode=default_mode) html_file = open(file_name, 'w') html_file.write("<html>\n <h1>%s</h1>\n" % title) html_file.write(raw_html) html_file.write(html_body) html_file.close() print("Created %s" % file_name)
def make_html(anim, file_name='anim.html', title=None, \ fps=None, embed_frames=True, default_mode='loop'): """ Take an animation created by make_anim and convert it into a stand-alone html file. """ from JSAnimation.IPython_display import anim_to_html html_body = anim_to_html(anim, fps=fps, embed_frames=embed_frames, \ default_mode=default_mode) html_file = open(file_name,'w') html_file.write("<html>\n <h1>%s</h1>\n" % title) html_file.write(html_body) html_file.close() print "Created %s" % file_name
def make_html(anim, file_name='anim.html', title=None, raw_html='', \ fps=None, embed_frames=True, default_mode='once'): """ Take an animation created by make_anim and convert it into a stand-alone html file. """ from JSAnimation.IPython_display import anim_to_html html_body = anim_to_html(anim, fps=fps, embed_frames=embed_frames, \ default_mode=default_mode) html_file = open(file_name,'w') html_file.write("<html>\n <h1>%s</h1>\n" % title) html_file.write(raw_html) html_file.write(html_body) html_file.close() print("Created %s" % file_name)
def make_html(anim, file_name='anim.html', title=None, raw_html='', \ fps=None, embed_frames=True, default_mode='once'): """ Take an animation created by make_anim and convert it into a stand-alone html file. """ if not found_JSAnim: raise ImportError('*** JSAnimation package not found') from JSAnimation.IPython_display import anim_to_html html_body = anim_to_html(anim, fps=fps, embed_frames=embed_frames, \ default_mode=default_mode) html_file = open(file_name, 'w') html_file.write("<html>\n <h1>%s</h1>\n" % title) html_file.write(raw_html) html_file.write(html_body) html_file.close() print("Created %s" % file_name)
def make_rst(anim, file_name='anim.rst', fps=None, embed_frames=True, default_mode='once'): """ Take an animation created by make_anim and convert it into an rst file (reStructuredText, for inclusion in Sphinx documentation, for example). """ from JSAnimation.IPython_display import anim_to_html rst_body = anim_to_html(anim, fps=fps, embed_frames=embed_frames, \ default_mode=default_mode) rst_body = rst_body.split('\n') rst_file = open(file_name,'w') rst_file.write(".. raw:: html\n") for line in rst_body: rst_file.write(" %s\n" % line) rst_file.close() print("Created %s" % file_name) print("Imbed this in another rst file using:") print(".. include:: %s" % file_name)