Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

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-controls - 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.

Filename, size & hash SHA256 hash help File type Python version Upload date
jupyter_manim-0.11.tar.gz (4.7 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page