mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Replace get_global_config() with manim_config, and make it an addict Dict
This commit is contained in:
parent
185f642826
commit
fce92347fa
10 changed files with 109 additions and 114 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from manimlib import __version__
|
from manimlib import __version__
|
||||||
from manimlib.config import get_global_config
|
from manimlib.config import manim_config
|
||||||
from manimlib.config import parse_cli
|
from manimlib.config import parse_cli
|
||||||
import manimlib.utils.init_config
|
import manimlib.utils.init_config
|
||||||
import manimlib.extract_scene
|
import manimlib.extract_scene
|
||||||
|
@ -19,13 +19,14 @@ def run_scenes():
|
||||||
"""
|
"""
|
||||||
Runs the scenes in a loop and detects when a scene reload is requested.
|
Runs the scenes in a loop and detects when a scene reload is requested.
|
||||||
"""
|
"""
|
||||||
global_config = get_global_config()
|
# Create a new dict to be able to upate without
|
||||||
scene_config = global_config["scene"]
|
# altering global configuration
|
||||||
run_config = global_config["run"]
|
scene_config = dict(manim_config.scene)
|
||||||
|
run_config = manim_config.run
|
||||||
|
|
||||||
if run_config["show_in_window"]:
|
if run_config.show_in_window:
|
||||||
# Create a reusable window
|
# Create a reusable window
|
||||||
window = Window(**global_config["window"])
|
window = Window(**manim_config.window)
|
||||||
scene_config.update(window=window)
|
scene_config.update(window=window)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -8,6 +8,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import yaml
|
import yaml
|
||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
|
from addict import Dict
|
||||||
|
|
||||||
from manimlib.logger import log
|
from manimlib.logger import log
|
||||||
from manimlib.utils.dict_ops import merge_dicts_recursively
|
from manimlib.utils.dict_ops import merge_dicts_recursively
|
||||||
|
@ -19,7 +20,7 @@ if TYPE_CHECKING:
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def initialize_global_config():
|
def initialize_manim_config() -> Dict:
|
||||||
"""
|
"""
|
||||||
Return default configuration for various classes in manim, such as
|
Return default configuration for various classes in manim, such as
|
||||||
Scene, Window, Camera, and SceneFileWriter, as well as configuration
|
Scene, Window, Camera, and SceneFileWriter, as well as configuration
|
||||||
|
@ -46,7 +47,7 @@ def initialize_global_config():
|
||||||
update_scene_config(config, args)
|
update_scene_config(config, args)
|
||||||
update_run_config(config, args)
|
update_run_config(config, args)
|
||||||
|
|
||||||
return config
|
return Dict(config)
|
||||||
|
|
||||||
|
|
||||||
def parse_cli():
|
def parse_cli():
|
||||||
|
@ -367,8 +368,8 @@ def get_animations_numbers(args: Namespace) -> tuple[int | None, int | None]:
|
||||||
return int(stan), None
|
return int(stan), None
|
||||||
|
|
||||||
|
|
||||||
def get_output_directory(args: Namespace, global_config: dict) -> str:
|
def get_output_directory(args: Namespace, config: dict) -> str:
|
||||||
dir_config = global_config["directories"]
|
dir_config = config["directories"]
|
||||||
output_directory = args.video_dir or dir_config["output"]
|
output_directory = args.video_dir or dir_config["output"]
|
||||||
if dir_config["mirror_module_path"] and args.file:
|
if dir_config["mirror_module_path"] and args.file:
|
||||||
to_cut = dir_config["removed_mirror_prefix"]
|
to_cut = dir_config["removed_mirror_prefix"]
|
||||||
|
@ -383,12 +384,7 @@ def get_output_directory(args: Namespace, global_config: dict) -> str:
|
||||||
# Create global configuration
|
# Create global configuration
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_CONFIG = initialize_global_config()
|
manim_config: Dict = initialize_manim_config()
|
||||||
|
|
||||||
|
|
||||||
def get_global_config():
|
|
||||||
global GLOBAL_CONFIG
|
|
||||||
return GLOBAL_CONFIG
|
|
||||||
|
|
||||||
|
|
||||||
# Shortcuts for retrieving portions of global configuration
|
# Shortcuts for retrieving portions of global configuration
|
||||||
|
@ -396,24 +392,24 @@ def get_global_config():
|
||||||
|
|
||||||
def get_window_config() -> dict:
|
def get_window_config() -> dict:
|
||||||
""" Key word arguments for Window """
|
""" Key word arguments for Window """
|
||||||
return get_global_config()["window"]
|
return manim_config.window
|
||||||
|
|
||||||
|
|
||||||
def get_camera_config() -> dict:
|
def get_camera_config() -> dict:
|
||||||
""" Key word arguments for Camera """
|
""" Key word arguments for Camera """
|
||||||
return get_global_config()["camera"]
|
return manim_config.camera
|
||||||
|
|
||||||
|
|
||||||
def get_file_writer_config() -> dict:
|
def get_file_writer_config() -> dict:
|
||||||
""" Key word arguments for SceneFileWriter """
|
""" Key word arguments for SceneFileWriter """
|
||||||
return get_global_config()["file_writer"]
|
return manim_config.file_writer
|
||||||
|
|
||||||
|
|
||||||
def get_scene_config() -> dict:
|
def get_scene_config() -> dict:
|
||||||
""" Key word arguments for Scene """
|
""" Key word arguments for Scene """
|
||||||
return get_global_config()["scene"]
|
return manim_config.scene
|
||||||
|
|
||||||
|
|
||||||
def get_run_config():
|
def get_run_config():
|
||||||
return get_global_config()["run"]
|
return manim_config.run
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,16 @@ if TYPE_CHECKING:
|
||||||
from manimlib.typing import ManimColor, Vect3
|
from manimlib.typing import ManimColor, Vect3
|
||||||
|
|
||||||
# See manimlib/default_config.yml
|
# See manimlib/default_config.yml
|
||||||
from manimlib.config import GLOBAL_CONFIG
|
from manimlib.config import manim_config
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_RESOLUTION: tuple[int, int] = GLOBAL_CONFIG["camera"]["resolution"]
|
DEFAULT_RESOLUTION: tuple[int, int] = manim_config.camera.resolution
|
||||||
DEFAULT_PIXEL_WIDTH: int = DEFAULT_RESOLUTION[0]
|
DEFAULT_PIXEL_WIDTH: int = DEFAULT_RESOLUTION[0]
|
||||||
DEFAULT_PIXEL_HEIGHT: int = DEFAULT_RESOLUTION[1]
|
DEFAULT_PIXEL_HEIGHT: int = DEFAULT_RESOLUTION[1]
|
||||||
|
|
||||||
# Sizes relevant to default camera frame
|
# Sizes relevant to default camera frame
|
||||||
ASPECT_RATIO: float = DEFAULT_PIXEL_WIDTH / DEFAULT_PIXEL_HEIGHT
|
ASPECT_RATIO: float = DEFAULT_PIXEL_WIDTH / DEFAULT_PIXEL_HEIGHT
|
||||||
FRAME_HEIGHT: float = GLOBAL_CONFIG["sizes"]["frame_height"]
|
FRAME_HEIGHT: float = manim_config.sizes.frame_height
|
||||||
FRAME_WIDTH: float = FRAME_HEIGHT * ASPECT_RATIO
|
FRAME_WIDTH: float = FRAME_HEIGHT * ASPECT_RATIO
|
||||||
FRAME_SHAPE: tuple[float, float] = (FRAME_WIDTH, FRAME_HEIGHT)
|
FRAME_SHAPE: tuple[float, float] = (FRAME_WIDTH, FRAME_HEIGHT)
|
||||||
FRAME_Y_RADIUS: float = FRAME_HEIGHT / 2
|
FRAME_Y_RADIUS: float = FRAME_HEIGHT / 2
|
||||||
|
@ -24,13 +24,13 @@ FRAME_X_RADIUS: float = FRAME_WIDTH / 2
|
||||||
|
|
||||||
|
|
||||||
# Helpful values for positioning mobjects
|
# Helpful values for positioning mobjects
|
||||||
SMALL_BUFF: float = GLOBAL_CONFIG["sizes"]["small_buff"]
|
SMALL_BUFF: float = manim_config.sizes.small_buff
|
||||||
MED_SMALL_BUFF: float = GLOBAL_CONFIG["sizes"]["med_small_buff"]
|
MED_SMALL_BUFF: float = manim_config.sizes.med_small_buff
|
||||||
MED_LARGE_BUFF: float = GLOBAL_CONFIG["sizes"]["med_large_buff"]
|
MED_LARGE_BUFF: float = manim_config.sizes.med_large_buff
|
||||||
LARGE_BUFF: float = GLOBAL_CONFIG["sizes"]["large_buff"]
|
LARGE_BUFF: float = manim_config.sizes.large_buff
|
||||||
|
|
||||||
DEFAULT_MOBJECT_TO_EDGE_BUFF: float = GLOBAL_CONFIG["sizes"]["default_mobject_to_edge_buff"]
|
DEFAULT_MOBJECT_TO_EDGE_BUFF: float = manim_config.sizes.default_mobject_to_edge_buff
|
||||||
DEFAULT_MOBJECT_TO_MOBJECT_BUFF: float = GLOBAL_CONFIG["sizes"]["default_mobject_to_mobject_buff"]
|
DEFAULT_MOBJECT_TO_MOBJECT_BUFF: float = manim_config.sizes.default_mobject_to_mobject_buff
|
||||||
|
|
||||||
|
|
||||||
# Standard vectors
|
# Standard vectors
|
||||||
|
@ -72,67 +72,65 @@ ITALIC: str = "ITALIC"
|
||||||
OBLIQUE: str = "OBLIQUE"
|
OBLIQUE: str = "OBLIQUE"
|
||||||
BOLD: str = "BOLD"
|
BOLD: str = "BOLD"
|
||||||
|
|
||||||
DEFAULT_STROKE_WIDTH: float = GLOBAL_CONFIG["vmobject"]["default_stroke_width"]
|
DEFAULT_STROKE_WIDTH: float = manim_config.vmobject.default_stroke_width
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
named_colors = GLOBAL_CONFIG["colors"]
|
BLUE_E: ManimColor = manim_config.colors.blue_e
|
||||||
|
BLUE_D: ManimColor = manim_config.colors.blue_d
|
||||||
|
BLUE_C: ManimColor = manim_config.colors.blue_c
|
||||||
|
BLUE_B: ManimColor = manim_config.colors.blue_b
|
||||||
|
BLUE_A: ManimColor = manim_config.colors.blue_a
|
||||||
|
TEAL_E: ManimColor = manim_config.colors.teal_e
|
||||||
|
TEAL_D: ManimColor = manim_config.colors.teal_d
|
||||||
|
TEAL_C: ManimColor = manim_config.colors.teal_c
|
||||||
|
TEAL_B: ManimColor = manim_config.colors.teal_b
|
||||||
|
TEAL_A: ManimColor = manim_config.colors.teal_a
|
||||||
|
GREEN_E: ManimColor = manim_config.colors.green_e
|
||||||
|
GREEN_D: ManimColor = manim_config.colors.green_d
|
||||||
|
GREEN_C: ManimColor = manim_config.colors.green_c
|
||||||
|
GREEN_B: ManimColor = manim_config.colors.green_b
|
||||||
|
GREEN_A: ManimColor = manim_config.colors.green_a
|
||||||
|
YELLOW_E: ManimColor = manim_config.colors.yellow_e
|
||||||
|
YELLOW_D: ManimColor = manim_config.colors.yellow_d
|
||||||
|
YELLOW_C: ManimColor = manim_config.colors.yellow_c
|
||||||
|
YELLOW_B: ManimColor = manim_config.colors.yellow_b
|
||||||
|
YELLOW_A: ManimColor = manim_config.colors.yellow_a
|
||||||
|
GOLD_E: ManimColor = manim_config.colors.gold_e
|
||||||
|
GOLD_D: ManimColor = manim_config.colors.gold_d
|
||||||
|
GOLD_C: ManimColor = manim_config.colors.gold_c
|
||||||
|
GOLD_B: ManimColor = manim_config.colors.gold_b
|
||||||
|
GOLD_A: ManimColor = manim_config.colors.gold_a
|
||||||
|
RED_E: ManimColor = manim_config.colors.red_e
|
||||||
|
RED_D: ManimColor = manim_config.colors.red_d
|
||||||
|
RED_C: ManimColor = manim_config.colors.red_c
|
||||||
|
RED_B: ManimColor = manim_config.colors.red_b
|
||||||
|
RED_A: ManimColor = manim_config.colors.red_a
|
||||||
|
MAROON_E: ManimColor = manim_config.colors.maroon_e
|
||||||
|
MAROON_D: ManimColor = manim_config.colors.maroon_d
|
||||||
|
MAROON_C: ManimColor = manim_config.colors.maroon_c
|
||||||
|
MAROON_B: ManimColor = manim_config.colors.maroon_b
|
||||||
|
MAROON_A: ManimColor = manim_config.colors.maroon_a
|
||||||
|
PURPLE_E: ManimColor = manim_config.colors.purple_e
|
||||||
|
PURPLE_D: ManimColor = manim_config.colors.purple_d
|
||||||
|
PURPLE_C: ManimColor = manim_config.colors.purple_c
|
||||||
|
PURPLE_B: ManimColor = manim_config.colors.purple_b
|
||||||
|
PURPLE_A: ManimColor = manim_config.colors.purple_a
|
||||||
|
GREY_E: ManimColor = manim_config.colors.grey_e
|
||||||
|
GREY_D: ManimColor = manim_config.colors.grey_d
|
||||||
|
GREY_C: ManimColor = manim_config.colors.grey_c
|
||||||
|
GREY_B: ManimColor = manim_config.colors.grey_b
|
||||||
|
GREY_A: ManimColor = manim_config.colors.grey_a
|
||||||
|
WHITE: ManimColor = manim_config.colors.white
|
||||||
|
BLACK: ManimColor = manim_config.colors.black
|
||||||
|
GREY_BROWN: ManimColor = manim_config.colors.grey_brown
|
||||||
|
DARK_BROWN: ManimColor = manim_config.colors.dark_brown
|
||||||
|
LIGHT_BROWN: ManimColor = manim_config.colors.light_brown
|
||||||
|
PINK: ManimColor = manim_config.colors.pink
|
||||||
|
LIGHT_PINK: ManimColor = manim_config.colors.light_pink
|
||||||
|
GREEN_SCREEN: ManimColor = manim_config.colors.green_screen
|
||||||
|
ORANGE: ManimColor = manim_config.colors.orange
|
||||||
|
|
||||||
BLUE_E: ManimColor = named_colors["blue_e"]
|
MANIM_COLORS: List[ManimColor] = list(manim_config.colors.values())
|
||||||
BLUE_D: ManimColor = named_colors["blue_d"]
|
|
||||||
BLUE_C: ManimColor = named_colors["blue_c"]
|
|
||||||
BLUE_B: ManimColor = named_colors["blue_b"]
|
|
||||||
BLUE_A: ManimColor = named_colors["blue_a"]
|
|
||||||
TEAL_E: ManimColor = named_colors["teal_e"]
|
|
||||||
TEAL_D: ManimColor = named_colors["teal_d"]
|
|
||||||
TEAL_C: ManimColor = named_colors["teal_c"]
|
|
||||||
TEAL_B: ManimColor = named_colors["teal_b"]
|
|
||||||
TEAL_A: ManimColor = named_colors["teal_a"]
|
|
||||||
GREEN_E: ManimColor = named_colors["green_e"]
|
|
||||||
GREEN_D: ManimColor = named_colors["green_d"]
|
|
||||||
GREEN_C: ManimColor = named_colors["green_c"]
|
|
||||||
GREEN_B: ManimColor = named_colors["green_b"]
|
|
||||||
GREEN_A: ManimColor = named_colors["green_a"]
|
|
||||||
YELLOW_E: ManimColor = named_colors["yellow_e"]
|
|
||||||
YELLOW_D: ManimColor = named_colors["yellow_d"]
|
|
||||||
YELLOW_C: ManimColor = named_colors["yellow_c"]
|
|
||||||
YELLOW_B: ManimColor = named_colors["yellow_b"]
|
|
||||||
YELLOW_A: ManimColor = named_colors["yellow_a"]
|
|
||||||
GOLD_E: ManimColor = named_colors["gold_e"]
|
|
||||||
GOLD_D: ManimColor = named_colors["gold_d"]
|
|
||||||
GOLD_C: ManimColor = named_colors["gold_c"]
|
|
||||||
GOLD_B: ManimColor = named_colors["gold_b"]
|
|
||||||
GOLD_A: ManimColor = named_colors["gold_a"]
|
|
||||||
RED_E: ManimColor = named_colors["red_e"]
|
|
||||||
RED_D: ManimColor = named_colors["red_d"]
|
|
||||||
RED_C: ManimColor = named_colors["red_c"]
|
|
||||||
RED_B: ManimColor = named_colors["red_b"]
|
|
||||||
RED_A: ManimColor = named_colors["red_a"]
|
|
||||||
MAROON_E: ManimColor = named_colors["maroon_e"]
|
|
||||||
MAROON_D: ManimColor = named_colors["maroon_d"]
|
|
||||||
MAROON_C: ManimColor = named_colors["maroon_c"]
|
|
||||||
MAROON_B: ManimColor = named_colors["maroon_b"]
|
|
||||||
MAROON_A: ManimColor = named_colors["maroon_a"]
|
|
||||||
PURPLE_E: ManimColor = named_colors["purple_e"]
|
|
||||||
PURPLE_D: ManimColor = named_colors["purple_d"]
|
|
||||||
PURPLE_C: ManimColor = named_colors["purple_c"]
|
|
||||||
PURPLE_B: ManimColor = named_colors["purple_b"]
|
|
||||||
PURPLE_A: ManimColor = named_colors["purple_a"]
|
|
||||||
GREY_E: ManimColor = named_colors["grey_e"]
|
|
||||||
GREY_D: ManimColor = named_colors["grey_d"]
|
|
||||||
GREY_C: ManimColor = named_colors["grey_c"]
|
|
||||||
GREY_B: ManimColor = named_colors["grey_b"]
|
|
||||||
GREY_A: ManimColor = named_colors["grey_a"]
|
|
||||||
WHITE: ManimColor = named_colors["white"]
|
|
||||||
BLACK: ManimColor = named_colors["black"]
|
|
||||||
GREY_BROWN: ManimColor = named_colors["grey_brown"]
|
|
||||||
DARK_BROWN: ManimColor = named_colors["dark_brown"]
|
|
||||||
LIGHT_BROWN: ManimColor = named_colors["light_brown"]
|
|
||||||
PINK: ManimColor = named_colors["pink"]
|
|
||||||
LIGHT_PINK: ManimColor = named_colors["light_pink"]
|
|
||||||
GREEN_SCREEN: ManimColor = named_colors["green_screen"]
|
|
||||||
ORANGE: ManimColor = named_colors["orange"]
|
|
||||||
|
|
||||||
MANIM_COLORS: List[ManimColor] = list(named_colors.values())
|
|
||||||
|
|
||||||
# Abbreviated names for the "median" colors
|
# Abbreviated names for the "median" colors
|
||||||
BLUE: ManimColor = BLUE_C
|
BLUE: ManimColor = BLUE_C
|
||||||
|
|
|
@ -6,7 +6,7 @@ import sys
|
||||||
|
|
||||||
from manimlib.module_loader import ModuleLoader
|
from manimlib.module_loader import ModuleLoader
|
||||||
|
|
||||||
from manimlib.config import get_global_config
|
from manimlib.config import manim_config
|
||||||
from manimlib.logger import log
|
from manimlib.logger import log
|
||||||
from manimlib.scene.interactive_scene import InteractiveScene
|
from manimlib.scene.interactive_scene import InteractiveScene
|
||||||
from manimlib.scene.scene import Scene
|
from manimlib.scene.scene import Scene
|
||||||
|
@ -19,7 +19,7 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
class BlankScene(InteractiveScene):
|
class BlankScene(InteractiveScene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
exec(get_global_config()["universal_import_line"])
|
exec(manim_config.universal_import_line)
|
||||||
self.embed()
|
self.embed()
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,13 +77,13 @@ def compute_total_frames(scene_class, scene_config):
|
||||||
pre_scene = scene_class(**pre_config)
|
pre_scene = scene_class(**pre_config)
|
||||||
pre_scene.run()
|
pre_scene.run()
|
||||||
total_time = pre_scene.time - pre_scene.skip_time
|
total_time = pre_scene.time - pre_scene.skip_time
|
||||||
return int(total_time * get_global_config()["camera"]["fps"])
|
return int(total_time * manim_config.camera.fps)
|
||||||
|
|
||||||
|
|
||||||
def scene_from_class(scene_class, scene_config, run_config):
|
def scene_from_class(scene_class, scene_config, run_config):
|
||||||
fw_config = get_global_config()["file_writer"]
|
fw_config = manim_config.file_writer
|
||||||
if fw_config["write_to_movie"] and run_config["prerun"]:
|
if fw_config.write_to_movie and run_config.prerun:
|
||||||
scene_config["file_writer_config"]["total_frames"] = compute_total_frames(scene_class, scene_config)
|
scene_config.file_writer_config.total_frames = compute_total_frames(scene_class, scene_config)
|
||||||
return scene_class(**scene_config)
|
return scene_class(**scene_config)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from colour import Color
|
from colour import Color
|
||||||
|
|
||||||
from manimlib.config import get_global_config
|
from manimlib.config import manim_config
|
||||||
from manimlib.constants import BLACK, RED, YELLOW, WHITE
|
from manimlib.constants import BLACK, RED, YELLOW, WHITE
|
||||||
from manimlib.constants import DL, DOWN, DR, LEFT, RIGHT, UL, UR
|
from manimlib.constants import DL, DOWN, DR, LEFT, RIGHT, UL, UR
|
||||||
from manimlib.constants import SMALL_BUFF
|
from manimlib.constants import SMALL_BUFF
|
||||||
|
@ -57,7 +57,7 @@ class BackgroundRectangle(SurroundingRectangle):
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
if color is None:
|
if color is None:
|
||||||
color = get_global_config()['style']['background_color']
|
color = manim_config.camera.background_color
|
||||||
super().__init__(
|
super().__init__(
|
||||||
mobject,
|
mobject,
|
||||||
color=color,
|
color=color,
|
||||||
|
|
|
@ -12,7 +12,7 @@ import pygments
|
||||||
import pygments.formatters
|
import pygments.formatters
|
||||||
import pygments.lexers
|
import pygments.lexers
|
||||||
|
|
||||||
from manimlib.config import get_global_config
|
from manimlib.config import manim_config
|
||||||
from manimlib.constants import DEFAULT_PIXEL_WIDTH, FRAME_WIDTH
|
from manimlib.constants import DEFAULT_PIXEL_WIDTH, FRAME_WIDTH
|
||||||
from manimlib.constants import NORMAL
|
from manimlib.constants import NORMAL
|
||||||
from manimlib.logger import log
|
from manimlib.logger import log
|
||||||
|
@ -151,20 +151,20 @@ class MarkupText(StringMobject):
|
||||||
t2g: dict = {}, # Overrides text2gradient if nonempty
|
t2g: dict = {}, # Overrides text2gradient if nonempty
|
||||||
t2s: dict = {}, # Overrides text2slant if nonempty
|
t2s: dict = {}, # Overrides text2slant if nonempty
|
||||||
t2w: dict = {}, # Overrides text2weight if nonempty
|
t2w: dict = {}, # Overrides text2weight if nonempty
|
||||||
global_config: dict = {},
|
global_attrs: dict = {},
|
||||||
local_configs: dict = {},
|
local_configs: dict = {},
|
||||||
disable_ligatures: bool = True,
|
disable_ligatures: bool = True,
|
||||||
isolate: Selector = re.compile(r"\w+", re.U),
|
isolate: Selector = re.compile(r"\w+", re.U),
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
text_config = get_global_config()["text"]
|
text_config = manim_config.text
|
||||||
self.text = text
|
self.text = text
|
||||||
self.font_size = font_size
|
self.font_size = font_size
|
||||||
self.justify = justify
|
self.justify = justify
|
||||||
self.indent = indent
|
self.indent = indent
|
||||||
self.alignment = alignment or text_config["alignment"]
|
self.alignment = alignment or text_config.alignment
|
||||||
self.line_width = line_width
|
self.line_width = line_width
|
||||||
self.font = font or text_config["font"]
|
self.font = font or text_config.font
|
||||||
self.slant = slant
|
self.slant = slant
|
||||||
self.weight = weight
|
self.weight = weight
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class MarkupText(StringMobject):
|
||||||
self.t2s = text2slant or t2s
|
self.t2s = text2slant or t2s
|
||||||
self.t2w = text2weight or t2w
|
self.t2w = text2weight or t2w
|
||||||
|
|
||||||
self.global_config = global_config
|
self.global_attrs = global_attrs
|
||||||
self.local_configs = local_configs
|
self.local_configs = local_configs
|
||||||
self.disable_ligatures = disable_ligatures
|
self.disable_ligatures = disable_ligatures
|
||||||
self.isolate = isolate
|
self.isolate = isolate
|
||||||
|
@ -362,7 +362,7 @@ class MarkupText(StringMobject):
|
||||||
if self.disable_ligatures:
|
if self.disable_ligatures:
|
||||||
global_attr_dict["font_features"] = "liga=0,dlig=0,clig=0,hlig=0"
|
global_attr_dict["font_features"] = "liga=0,dlig=0,clig=0,hlig=0"
|
||||||
|
|
||||||
global_attr_dict.update(self.global_config)
|
global_attr_dict.update(self.global_attrs)
|
||||||
return tuple(
|
return tuple(
|
||||||
self.get_command_string(
|
self.get_command_string(
|
||||||
global_attr_dict,
|
global_attr_dict,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
|
|
||||||
from manimlib.config import get_global_config
|
from manimlib.config import manim_config
|
||||||
from manimlib.logger import log
|
from manimlib.logger import log
|
||||||
|
|
||||||
Module = importlib.util.types.ModuleType
|
Module = importlib.util.types.ModuleType
|
||||||
|
@ -142,7 +142,7 @@ class ModuleLoader:
|
||||||
|
|
||||||
Only user-defined modules are reloaded, see `is_user_defined_module()`.
|
Only user-defined modules are reloaded, see `is_user_defined_module()`.
|
||||||
"""
|
"""
|
||||||
ignore_manimlib_modules = get_global_config()["ignore_manimlib_modules_on_reload"]
|
ignore_manimlib_modules = manim_config.ignore_manimlib_modules_on_reload
|
||||||
if ignore_manimlib_modules and module.__name__.startswith("manimlib"):
|
if ignore_manimlib_modules and module.__name__.startswith("manimlib"):
|
||||||
return
|
return
|
||||||
if module.__name__.startswith("manimlib.config"):
|
if module.__name__.startswith("manimlib.config"):
|
||||||
|
|
|
@ -7,7 +7,7 @@ from IPython.terminal import pt_inputhooks
|
||||||
from IPython.terminal.embed import InteractiveShellEmbed
|
from IPython.terminal.embed import InteractiveShellEmbed
|
||||||
|
|
||||||
from manimlib.animation.fading import VFadeInThenOut
|
from manimlib.animation.fading import VFadeInThenOut
|
||||||
from manimlib.config import get_global_config
|
from manimlib.config import manim_config
|
||||||
from manimlib.constants import RED
|
from manimlib.constants import RED
|
||||||
from manimlib.mobject.mobject import Mobject
|
from manimlib.mobject.mobject import Mobject
|
||||||
from manimlib.mobject.frame import FullScreenRectangle
|
from manimlib.mobject.frame import FullScreenRectangle
|
||||||
|
@ -40,7 +40,7 @@ def get_ipython_shell_for_embedded_scene(scene):
|
||||||
module = ModuleLoader.get_module(caller_frame.f_globals["__file__"])
|
module = ModuleLoader.get_module(caller_frame.f_globals["__file__"])
|
||||||
module.__dict__.update(caller_frame.f_locals)
|
module.__dict__.update(caller_frame.f_locals)
|
||||||
module.__dict__.update(get_shortcuts(scene))
|
module.__dict__.update(get_shortcuts(scene))
|
||||||
exception_mode = get_global_config()["embed"]["exception_mode"]
|
exception_mode = manim_config.embed.exception_mode
|
||||||
|
|
||||||
return InteractiveShellEmbed(
|
return InteractiveShellEmbed(
|
||||||
user_module=module,
|
user_module=module,
|
||||||
|
@ -132,10 +132,10 @@ def reload_scene(embed_line: int | None = None) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Update the global run configuration.
|
# Update the global run configuration.
|
||||||
run_config = get_global_config()["run"]
|
run_config = manim_config.run
|
||||||
run_config["is_reload"] = True
|
run_config.is_reload = True
|
||||||
if embed_line:
|
if embed_line:
|
||||||
run_config["embed_line"] = embed_line
|
run_config.embed_line = embed_line
|
||||||
|
|
||||||
print("Reloading...")
|
print("Reloading...")
|
||||||
shell.run_line_magic("exit_raise", "")
|
shell.run_line_magic("exit_raise", "")
|
||||||
|
|
|
@ -5,13 +5,13 @@ import tempfile
|
||||||
import appdirs
|
import appdirs
|
||||||
|
|
||||||
|
|
||||||
from manimlib.config import get_global_config
|
from manimlib.config import manim_config
|
||||||
from manimlib.config import get_manim_dir
|
from manimlib.config import get_manim_dir
|
||||||
from manimlib.utils.file_ops import guarantee_existence
|
from manimlib.utils.file_ops import guarantee_existence
|
||||||
|
|
||||||
|
|
||||||
def get_directories() -> dict[str, str]:
|
def get_directories() -> dict[str, str]:
|
||||||
return get_global_config()["directories"]
|
return manim_config.directories
|
||||||
|
|
||||||
|
|
||||||
def get_cache_dir() -> str:
|
def get_cache_dir() -> str:
|
||||||
|
|
|
@ -10,7 +10,7 @@ from pathlib import Path
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from manimlib.utils.cache import cache_on_disk
|
from manimlib.utils.cache import cache_on_disk
|
||||||
from manimlib.config import get_global_config
|
from manimlib.config import manim_config
|
||||||
from manimlib.config import get_manim_dir
|
from manimlib.config import get_manim_dir
|
||||||
from manimlib.logger import log
|
from manimlib.logger import log
|
||||||
from manimlib.utils.simple_functions import hash_string
|
from manimlib.utils.simple_functions import hash_string
|
||||||
|
@ -40,7 +40,7 @@ def get_tex_config(template: str = "") -> dict[str, str]:
|
||||||
"preamble": "..."
|
"preamble": "..."
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
template = template or get_global_config()["tex"]["template"]
|
template = template or manim_config.tex.template
|
||||||
template_config = get_tex_template_config(template)
|
template_config = get_tex_template_config(template)
|
||||||
return {
|
return {
|
||||||
"template": template,
|
"template": template,
|
||||||
|
|
Loading…
Add table
Reference in a new issue