-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from jeertmans/manimgl
feat: add support for manimgl
- Loading branch information
Showing
6 changed files
with
137 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,7 @@ __pycache__/ | |
slides/ | ||
|
||
.manim-slides.json | ||
|
||
videos/ | ||
|
||
images/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import sys | ||
from importlib.util import find_spec | ||
|
||
MANIM_PACKAGE_NAME = "manim" | ||
MANIM_AVAILABLE = find_spec(MANIM_PACKAGE_NAME) is not None | ||
MANIM_IMPORTED = MANIM_PACKAGE_NAME in sys.modules | ||
|
||
MANIMGL_PACKAGE_NAME = "manimlib" | ||
MANIMGL_AVAILABLE = find_spec(MANIMGL_PACKAGE_NAME) is not None | ||
MANIMGL_IMPORTED = MANIMGL_PACKAGE_NAME in sys.modules | ||
|
||
if MANIM_IMPORTED and MANIMGL_IMPORTED: | ||
from manim import logger | ||
|
||
logger.warn( | ||
"Both manim and manimgl are installed, therefore `manim-slide` needs to need which one to use. Please only import one of the two modules so that `manim-slide` knows which one to use. Here, manim is used by default" | ||
) | ||
MANIM = True | ||
MANIMGL = False | ||
elif MANIM_AVAILABLE and not MANIMGL_IMPORTED: | ||
MANIM = True | ||
MANIMGL = False | ||
elif MANIMGL_AVAILABLE: | ||
MANIM = False | ||
MANIMGL = True | ||
else: | ||
raise ImportError( | ||
"Either manim (community) or manimgl (3b1b) package must be installed" | ||
) | ||
|
||
|
||
FFMPEG_BIN = None | ||
|
||
if MANIMGL: | ||
from manimlib import Scene, ThreeDScene, config | ||
from manimlib.constants import FFMPEG_BIN | ||
from manimlib.logger import log as logger | ||
|
||
else: | ||
from manim import Scene, ThreeDScene, config, logger | ||
|
||
try: # For manim<v0.16.0.post0 | ||
from manim.constants import FFMPEG_BIN as FFMPEG_BIN | ||
except ImportError: | ||
FFMPEG_BIN = config.ffmpeg_executable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters