Skip to main content

Cell magic rendering displaying videos in Jupyter/IPython

Project description

MIT License

Integrates manim (animation engine for explanatory math videos) with Jupyter displaying the resulting video when using %%manim cell magic to wrap a scene definition.

Quick preview

The code in the example above comes from the excellent manim tutorial.

Installation

pip3 install jupyter-manim

Usage

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_manim-0.1.tar.gz (4.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page