ManimMagic#
Qualified name: manim.utils.ipython\_magic.ManimMagic
- class ManimMagic(**kwargs)[source]#
Bases:
MagicsCreate a configurable given a config config.
- Parameters
config (Config) – If this is empty, default values are used. If config is a
Configinstance, it will be used to configure the instance.parent (Configurable instance, optional) – The parent Configurable instance of this object.
args (Any) –
kwargs (Any) –
- Return type
Any
Notes
Subclasses of Configurable must call the
__init__()method ofConfigurablebefore doing anything else and usingsuper():class MyConfigurable(Configurable): def __init__(self, config=None): super(MyConfigurable, self).__init__(config=config) # Then any other code you need to finish initialization.
This ensures that instances will be configured properly.
Methods
add_additional_argsRender Manim scenes contained in IPython cells.
Attributes
configA trait whose value must be an instance of a specified class.
cross_validation_lockA contextmanager for running a block with our cross validation lock set to True.
magicsoptions_tableparentA trait whose value must be an instance of a specified class.
registeredshell- manim(line, cell=None, local_ns=None)[source]#
Render Manim scenes contained in IPython cells. Works as a line or cell magic.
Hint
This line and cell magic works best when used in a JupyterLab environment: while all of the functionality is available for classic Jupyter notebooks as well, it is possible that videos sometimes don’t update on repeated execution of the same cell if the scene name stays the same.
This problem does not occur when using JupyterLab.
Please refer to https://jupyter.org/ for more information about JupyterLab and Jupyter notebooks.
Usage in line mode:
%manim [CLI options] MyAwesomeScene
Usage in cell mode:
%%manim [CLI options] MyAwesomeScene class MyAweseomeScene(Scene): def construct(self): ...
Run
%manim --helpand%manim render --helpfor possible command line interface options.Note
The maximal width of the rendered videos that are displayed in the notebook can be configured via the
media_widthconfiguration option. The default is set to25vw, which is 25% of your current viewport width. To allow the output to become as large as possible, setconfig.media_width = "100%".The
media_embedoption will embed the image/video output in the notebook. This is generally undesirable as it makes the notebooks very large, but is required on some platforms (notably Google’s CoLab, where it is automatically enabled unless suppressed byconfig.embed = False) and needed in cases when the notebook (or converted HTML file) will be moved relative to the video locations. Use-cases include building documentation with Sphinx and JupyterBook. See also themanim directive for Sphinx.Examples
First make sure to put
import manim, or evenfrom manim import *in a cell and evaluate it. Then, a typical Jupyter notebook cell for Manim could look as follows:%%manim -v WARNING --disable_caching -qm BannerExample config.media_width = "75%" config.media_embed = True class BannerExample(Scene): def construct(self): self.camera.background_color = "#ece6e2" banner_large = ManimBanner(dark_theme=False).scale(0.7) self.play(banner_large.create()) self.play(banner_large.expand())
Evaluating this cell will render and display the
BannerExamplescene defined in the body of the cell.Note
In case you want to hide the red box containing the output progress bar, the
progress_barconfig option should be set toNone. This can also be done by passing--progress_bar Noneas a CLI flag.- Parameters
line (str) –
cell (str) –
local_ns (dict[str, Any]) –
- Return type
None