2021-02-07 17:43:05 +08:00
|
|
|
#!/usr/bin/env python
|
2024-12-11 10:33:50 -06:00
|
|
|
from addict import Dict
|
|
|
|
|
2022-04-12 19:19:59 +08:00
|
|
|
from manimlib import __version__
|
2024-12-11 09:50:17 -06:00
|
|
|
from manimlib.config import manim_config
|
2024-12-10 15:46:17 -06:00
|
|
|
from manimlib.config import parse_cli
|
|
|
|
import manimlib.extract_scene
|
|
|
|
from manimlib.window import Window
|
|
|
|
|
|
|
|
|
|
|
|
from IPython.terminal.embed import KillEmbedded
|
|
|
|
|
|
|
|
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from argparse import Namespace
|
|
|
|
|
|
|
|
|
|
|
|
def run_scenes():
|
|
|
|
"""
|
|
|
|
Runs the scenes in a loop and detects when a scene reload is requested.
|
|
|
|
"""
|
2024-12-11 09:50:17 -06:00
|
|
|
# Create a new dict to be able to upate without
|
|
|
|
# altering global configuration
|
2024-12-11 10:33:50 -06:00
|
|
|
scene_config = Dict(manim_config.scene)
|
2024-12-11 09:50:17 -06:00
|
|
|
run_config = manim_config.run
|
2024-12-10 15:46:17 -06:00
|
|
|
|
2024-12-11 09:50:17 -06:00
|
|
|
if run_config.show_in_window:
|
2024-12-10 15:46:17 -06:00
|
|
|
# Create a reusable window
|
2024-12-11 09:50:17 -06:00
|
|
|
window = Window(**manim_config.window)
|
2024-12-10 15:46:17 -06:00
|
|
|
scene_config.update(window=window)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
# Blocking call since a scene may init an IPython shell()
|
|
|
|
scenes = manimlib.extract_scene.main(scene_config, run_config)
|
|
|
|
for scene in scenes:
|
|
|
|
scene.run()
|
|
|
|
return
|
|
|
|
except KillEmbedded:
|
|
|
|
# Requested via the `exit_raise` IPython runline magic
|
|
|
|
# by means of the reload_scene() command
|
|
|
|
pass
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
break
|
2021-02-07 17:43:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2024-11-26 19:09:43 +01:00
|
|
|
"""
|
|
|
|
Main entry point for ManimGL.
|
|
|
|
"""
|
2021-10-07 17:42:23 +08:00
|
|
|
print(f"ManimGL \033[32mv{__version__}\033[0m")
|
2021-10-16 13:04:52 +08:00
|
|
|
|
2024-12-10 15:46:17 -06:00
|
|
|
args = parse_cli()
|
2021-11-30 11:28:26 -08:00
|
|
|
if args.version and args.file is None:
|
2021-10-07 17:42:23 +08:00
|
|
|
return
|
2021-02-25 08:48:50 -08:00
|
|
|
|
2024-12-10 15:46:17 -06:00
|
|
|
run_scenes()
|
2021-04-09 20:17:21 +08:00
|
|
|
|
2021-11-30 11:28:26 -08:00
|
|
|
|
2021-10-16 13:04:52 +08:00
|
|
|
if __name__ == "__main__":
|
2021-04-09 20:17:21 +08:00
|
|
|
main()
|