Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krassowski/jupyter-manim
manim cell magic for IPython/Jupyter to show the output video
https://github.com/krassowski/jupyter-manim
ipython-magic jupyer jupyter-magic manim
Last synced: 18 days ago
JSON representation
manim cell magic for IPython/Jupyter to show the output video
- Host: GitHub
- URL: https://github.com/krassowski/jupyter-manim
- Owner: krassowski
- License: mit
- Created: 2019-05-22T14:18:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-02T21:32:22.000Z (almost 3 years ago)
- Last Synced: 2024-11-15T05:29:16.707Z (27 days ago)
- Topics: ipython-magic, jupyer, jupyter-magic, manim
- Language: Python
- Homepage:
- Size: 107 KB
- Stars: 196
- Watchers: 14
- Forks: 11
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-jupyter-resources - GitHub - 24% open · ⏱️ 02.01.2022): (Jupyter-magic拓展)
- awesome-jupyter - jupyter-manim - Display [manim](https://github.com/3b1b/manim) (Mathematical Animation Engine) videos or GIFs in Jupyter notebooks. (Visualization)
README
# jupyter-manim
[![Build Status](https://travis-ci.org/krassowski/jupyter-manim.svg?branch=master)](https://travis-ci.org/krassowski/jupyter-manim)
[![codecov](https://codecov.io/gh/krassowski/jupyter-manim/branch/master/graph/badge.svg)](https://codecov.io/gh/krassowski/jupyter-manim)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://choosealicense.com/licenses/mit/)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/krassowski/jupyter-manim/master?filepath=Example.ipynb)
[![Colab](https://camo.githubusercontent.com/52feade06f2fecbf006889a904d221e6a730c194/68747470733a2f2f636f6c61622e72657365617263682e676f6f676c652e636f6d2f6173736574732f636f6c61622d62616467652e737667)](https://colab.research.google.com/gist/cjds/825d9acc80cb0b92bb877bbe2f468d70/example-jupyter-manim.ipynb)Integrates 3b1b's [ManimCairo](https://github.com/3b1b/manim) (cairo-backend branch)
with Jupyter displaying the resulting video when using `%%manim` cell magic to wrap a scene definition.**WARNING**: This library only works for ManimCairo (the cairo-backend branch in 3b1b's version). It does not work for ManimCE (which already has Jupyter support by default)
or ManimGL (which does not support Jupyter at all, as of time of writing).### Quick preview
The code in the example above comes from the excellent [manim tutorial](https://github.com/malhotra5/Manim-Tutorial).
Run a live demo in your browser [by clicking here](https://mybinder.org/v2/gh/krassowski/jupyter-manim/master?filepath=Example.ipynb).
### Installation
```sh
pip3 install jupyter-manim
```### Usage
To enable the manim magic please run `import jupyter_manim` first. Then, you can use the magic as if it was the manim command: 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
```python
%%manim Shapes
from manimlib.scene.scene import Scene
from manimlib.mobject.geometry import Circle
from manimlib.animation.creation import ShowCreationclass Shapes(Scene):
def construct(self):
circle = Circle()
self.play(ShowCreation(circle))
```Since version 1.0, the code is no longer required to be self-contained -
`jupyter_manim` will attempt to export your variables (and imported objects) from the notebook into the manim script.Most variables can be easily exported, however there are limitations; in short [everything which can be pickled](https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled) can be exported. Additionally, variables whose names start with an underscore will be ommited.
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` flagIn the latest version of manimlib you can import everything at once using:
```python
from manimlib.imports import *
```#### 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`
- `--base64` send the video with a `data:` URL instead of a local path - useful for remote notebooks like Google Colab,
or to embed the video in notebook (note: the notebook size may increase rapidly)### Compatibility and testing
This package is continuously tested with Python 3.7 on Ubuntu, Mac OS an Windows.
Tests have to be run with ipython, as the magic relies on IPython instance being available:
```bash
python3 setup.py install
ipython -m pytest -- --cov=.
```