
* test: re-add opencv-python * chore(dev): move to Rye instead of PDM * try fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: build backend * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: string quotes? * small fixes * upgrade typing * fix(ci): rye install on Windows * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(ci): typos * fix * fix(ci): actually use right python version * fix(deps): manimgl * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix docs * another fix * cleanup * make sure to use trusted publisher * chore(docs): remove PDM --------- 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
.