
* refactor(lib): change how manim API is imported * chore(lib): delete old files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip: moving all commands * adding animations * fix tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix mypy * fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * trying to fix docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip: docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make it work * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip test * tests are working * improving docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix index * docs: nicer shift * docs: nicer quickstart example * fix tests * change tests * move coverage to test workflow * fix(tests): remove resolve * strict resolve * change local path test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * documented changes * cleanup docs * cleanup files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(ci): set type --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1.8 KiB
Manim or ManimGL
Manim Slides supports both Manim (Community Edition) and ManimGL (by 3b1b).
Because both modules have slightly different APIs, Manim Slides needs to know which Manim API you are using, to import the correct module.
Default Behavior
By default, Manim Slides looks at {py:data}sys.modules
and chooses the first
Manim package that is already imported: manim
for Manim,
manimlib
for ManimGL. This works pretty well when rendering
the slides.
If both modules are present in {py:data}sys.modules
, then Manim Slides will
prefer using manim
.
Usage
The simplest way to use Manim Slides with the correct Manim API is to:
- first import the Manim API;
- and, then, import
manim_slides
.
Example for manim
:
from manim import *
from manim_slides import Slide
Example for manimlib
:
from manimlib import *
from manim_slides import Slide
Example of Default Import
The following code shows how Manim Slides detected that manimlib
was imported, so the {py:class}Slide<manim_slides.slide.Slide>
automatically subclasses the class from ManimGL, not Manim.
from manimlib import Scene
from manim_slides import Slide
assert issubclass(Slide, Scene) # Slide subclasses Scene from ManimGL
from manim import Scene
assert not issubclass(Slide, Scene) # but not Scene from Manim
Custom Manim API
If you want to override the default Manim API, you can set the MANIM_API
environment variable to:
manim
ormanimce
to importmanim
;manimlib
ormanimgl
to importmanimlib
;
prior to importing manim_slides
.
Note that Manim Slides will still first look at {py:data}sys.modules
to check
if any of the two modules is already imported.
If you want to force Manim Slides to obey the MANIM_API
environment variable,
you must also set FORCE_MANIM_API=1
.