Cell magic rendering displaying videos in Jupyter/IPython
Integrates manim (animation engine for explanatory math videos) with Jupyter displaying the resulting video when using %%manim cell magic to wrap a scene definition.
The code in the example above comes from the excellent manim tutorial.
pip3 install jupyter-manim
Your arguments will be passed to manim, exactly as if these were command line options.
For example, to render scene defined with class Shapes(Scene) use
%%manim Shapes from manimlib.scene.scene import Scene from manimlib.mobject.geometry import Circle from manimlib.animation.creation import ShowCreation class Shapes(Scene): def construct(self): circle = Circle() self.play(ShowCreation(circle))
NOTE: currently the code has to be self-contained as it will be run in a separate namespace. Thus, all the imports have to be contained in your cell.
In future, an option to export the current namespace (or specific variables) will be added. It could be implemented by pickling the Python locals and globals and then pre-pending the cell with an un-pickling script (PRs welcome!).
In the latest version of manimlib (not yet released) you will be able to import everything at once using:
from manimlib.imports import *
To display manim help and options use:
%%manim -h pass
The %%manim magic (by default) hides the progress bars as well as other logging messages generated by manim. You can disable this behaviour using --verbose flag
Video player control options
- --no-control - hides the controls
- --no-autoplay - disables the autoplay feature
- -r or --resolution - control the height and width of the video player; this option is shared with manim and requires the resolution in following format: height,width, e.g. %%manim Shapes -r 200,1000
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size jupyter_manim-0.1.tar.gz (4.5 kB)||File type Source||Python version None||Upload date||Hashes View|