A community-maintained Python framework for creating mathematical animations.
typed constants.py typed movement.py typed numbers.py typed rotation.py typed transform.py typed update.py
Syrus Dark1bd198398471
diff --git a/manim/animation/movement.py b/manim/animation/movement.pyindex 7c258a5ec..2a784b408 100644--- a/manim/animation/movement.py+++ b/manim/animation/movement.py@@ -9,45 +9,72 @@ __all__ = []+import typing++import numpy as np+from ..animation.animation import Animationfrom ..utils.rate_functions import linear+if typing.TYPE_CHECKING:+ from ..mobject.mobject import Mobject+class Homotopy(Animation):def __init__(- self, homotopy, mobject, run_time=3, apply_function_kwargs={}, **kwargs- ):+ self,+ homotopy: typing.Callable[+ [float, float, float, float], typing.Tuple[float, float, float]+ ],+ mobject: "Mobject",+ run_time: typing.Optional[float] = 3,+ apply_function_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None,+ **kwargs+ ) -> None:"""Homotopy is a function from(x, y, z, t) to (x', y', z')"""self.homotopy = homotopy- self.apply_function_kwargs = apply_function_kwargs+ self.apply_function_kwargs = (+ apply_function_kwargs if apply_function_kwargs is not None else {}+ )super().__init__(mobject, run_time=run_time, **kwargs)- def function_at_time_t(self, t):+ def function_at_time_t(self, t: float) -> typing.Tuple[float, float, float]:return lambda p: self.homotopy(*p, t)- def interpolate_submobject(self, submob, start, alpha):- submob.points = start.points- submob.apply_function(+ def interpolate_submobject(+ self, submobject: "Mobject", starting_sumobject: "Mobject", alpha: float+ ) -> None:+ submobject.points = starting_sumobject.points+ submobject.apply_function(self.function_at_time_t(alpha), **self.apply_function_kwargs)class SmoothedVectorizedHomotopy(Homotopy):- def interpolate_submobject(self, submob, start, alpha):- Homotopy.interpolate_submobject(self, submob, start, alpha)- submob.make_smooth()+ def interpolate_submobject(+ self, submobject: "Mobject", starting_sumobject: "Mobject", alpha: float+ ) -> None:+ Homotopy.interpolate_submobject(self, submobject, starting_sumobject, alpha)+ submobject.make_smooth()class ComplexHomotopy(Homotopy):- def __init__(self, complex_homotopy, mobject, **kwargs):+ def __init__(+ self,+ complex_homotopy: typing.Callable[[complex], float],+ mobject: "Mobject",+ **kwargs+ ) -> None:"""Complex Hootopy a function Cx[0, 1] to C"""- def homotopy(x, y, z, t):+ def homotopy(+ x: float, y: float, z: float, t: float+ ) -> typing.Tuple[float, float, float]:c = complex_homotopy(complex(x, y), t)return (c.real, c.imag, z)@@ -57,13 +84,17 @@ class ComplexHomotopy(Homotopy):class PhaseFlow(Animation):def __init__(self,- function,- mobject,- virtual_time=1,- suspend_mobject_updating=False,- rate_func=linear,+ function: typing.Callable[[np.ndarray], np.ndarray],+ mobject: "Mobject",+ virtual_time: typing.Optional[float] = 1,+ suspend_mobject_updating: typing.Optional[bool] = False,+ rate_func: typing.Optional[+ typing.Callable[+ [typing.Union[np.ndarray, float]], typing.Union[np.ndarray, float]+ ]+ ] = linear,**kwargs- ):+ ) -> None:self.virtual_time = virtual_timeself.function = functionsuper().__init__(@@ -73,7 +104,7 @@ class PhaseFlow(Animation):**kwargs)- def interpolate_mobject(self, alpha):+ def interpolate_mobject(self, alpha: float) -> None:if hasattr(self, "last_alpha"):dt = self.virtual_time * (alpha - self.last_alpha)self.mobject.apply_function(lambda p: p + dt * self.function(p))@@ -81,12 +112,18 @@ class PhaseFlow(Animation):class MoveAlongPath(Animation):- def __init__(self, mobject, path, suspend_mobject_updating=False, **kwargs):+ def __init__(+ self,+ mobject: "Mobject",+ path: np.ndarray,+ suspend_mobject_updating: typing.Optional[bool] = False,+ **kwargs+ ) -> None:self.path = pathsuper().__init__(mobject, suspend_mobject_updating=suspend_mobject_updating, **kwargs)- def interpolate_mobject(self, alpha):+ def interpolate_mobject(self, alpha: float) -> None:point = self.path.point_from_proportion(alpha)self.mobject.move_to(point)diff --git a/manim/animation/numbers.py b/manim/animation/numbers.pyindex cde3049a0..b0285d48a 100644--- a/manim/animation/numbers.py+++ b/manim/animation/numbers.py@@ -3,6 +3,7 @@__all__ = ["ChangingDecimal", "ChangeDecimalToValue"]+import typingimport warningsfrom ..animation.animation import Animation@@ -12,8 +13,12 @@ from ..utils.bezier import interpolateclass ChangingDecimal(Animation):def __init__(- self, decimal_mob, number_update_func, suspend_mobject_updating=False, **kwargs- ):+ self,+ decimal_mob: DecimalNumber,+ number_update_func: typing.Callable[[float], float],+ suspend_mobject_updating: typing.Optional[bool] = False,+ **kwargs+ ) -> None:self.check_validity_of_input(decimal_mob)self.yell_about_depricated_configuration(**kwargs)self.number_update_func = number_update_func@@ -21,11 +26,11 @@ class ChangingDecimal(Animation):decimal_mob, suspend_mobject_updating=suspend_mobject_updating, **kwargs)- def check_validity_of_input(self, decimal_mob):+ def check_validity_of_input(self, decimal_mob: DecimalNumber) -> None:if not isinstance(decimal_mob, DecimalNumber):raise TypeError("ChangingDecimal can only take in a DecimalNumber")- def yell_about_depricated_configuration(self, **kwargs):+ def yell_about_depricated_configuration(self, **kwargs) -> None:# Obviously this would optimally be removed at# some point.for attr in ["tracked_mobject", "position_update_func"]:@@ -41,12 +46,14 @@ class ChangingDecimal(Animation):))- def interpolate_mobject(self, alpha):+ def interpolate_mobject(self, alpha: float) -> None:self.mobject.set_value(self.number_update_func(alpha))class ChangeDecimalToValue(ChangingDecimal):- def __init__(self, decimal_mob, target_number, **kwargs):+ def __init__(+ self, decimal_mob: DecimalNumber, target_number: int, **kwargs+ ) -> None:start_number = decimal_mob.numbersuper().__init__(decimal_mob, lambda a: interpolate(start_number, target_number, a), **kwargsdiff --git a/manim/animation/rotation.py b/manim/animation/rotation.pyindex bb78cdcf8..78b3baee5 100644--- a/manim/animation/rotation.py+++ b/manim/animation/rotation.py@@ -2,34 +2,40 @@__all__ = ["Rotating", "Rotate"]+import typing++import numpy as npfrom ..animation.animation import Animationfrom ..animation.transform import Transform-from ..constants import OUT-from ..constants import PI-from ..constants import TAU+from ..constants import OUT, PI, TAUfrom ..utils.rate_functions import linear+if typing.TYPE_CHECKING:+ from ..mobject.mobject import Mobject+class Rotating(Animation):def __init__(self,- mobject,- axis=OUT,- radians=TAU,- about_point=None,- about_edge=None,- run_time=5,- rate_func=linear,+ mobject: "Mobject",+ axis: typing.Optional[np.ndarray] = OUT,+ radians: typing.Optional[np.ndarray] = TAU,+ about_point: typing.Optional[np.ndarray] = None,+ about_edge: typing.Optional[np.ndarray] = None,+ run_time: typing.Optional[float] = 5,+ rate_func: typing.Callable[+ [typing.Union[np.ndarray, float]], typing.Union[np.ndarray, float]+ ] = linear,**kwargs- ):+ ) -> None:self.axis = axisself.radians = radiansself.about_point = about_pointself.about_edge = about_edgesuper().__init__(mobject, run_time=run_time, rate_func=rate_func, **kwargs)- def interpolate_mobject(self, alpha):+ def interpolate_mobject(self, alpha: float) -> None:self.mobject.become(self.starting_mobject)self.mobject.rotate(alpha * self.radians,@@ -41,8 +47,14 @@ class Rotating(Animation):class Rotate(Transform):def __init__(- self, mobject, angle=PI, axis=OUT, about_point=None, about_edge=None, **kwargs- ):+ self,+ mobject: "Mobject",+ angle: typing.Optional[np.ndarray] = PI,+ axis: typing.Optional[np.ndarray] = OUT,+ about_point: typing.Optional[np.ndarray] = None,+ about_edge: typing.Optional[np.ndarray] = None,+ **kwargs+ ) -> None:if "path_arc" not in kwargs:kwargs["path_arc"] = angleif "path_arc_axis" not in kwargs:@@ -53,7 +65,7 @@ class Rotate(Transform):self.about_point = about_pointsuper().__init__(mobject, **kwargs)- def create_target(self):+ def create_target(self) -> "Mobject":target = self.mobject.copy()target.rotate(self.angle,diff --git a/manim/animation/transform.py b/manim/animation/transform.pyindex cebaef883..e389635bb 100644--- a/manim/animation/transform.py+++ b/manim/animation/transform.py@@ -22,34 +22,33 @@ __all__ = ["TransformAnimations",]-import inspect+import types+import typingimport numpy as npfrom ..animation.animation import Animation-from ..constants import DEFAULT_POINTWISE_FUNCTION_RUN_TIME-from ..constants import OUT-from ..constants import DEGREES-from ..mobject.mobject import Group-from ..mobject.mobject import Mobject-from ..utils.paths import path_along_arc-from ..utils.paths import straight_path-from ..utils.rate_functions import smooth-from ..utils.rate_functions import squish_rate_func+from ..constants import DEFAULT_POINTWISE_FUNCTION_RUN_TIME, DEGREES, OUT+from ..mobject.mobject import Group, Mobject+from ..utils.paths import path_along_arc, straight_path+from ..utils.rate_functions import smooth, squish_rate_func++if typing.TYPE_CHECKING:+ from ..scene.scene import Sceneclass Transform(Animation):def __init__(self,- mobject,- target_mobject=None,- path_func=None,- path_arc=0,- path_arc_axis=OUT,- replace_mobject_with_target_in_scene=False,+ mobject: Mobject,+ target_mobject: typing.Optional[Mobject] = None,+ path_func: typing.Optional[typing.Callable] = None,+ path_arc: float = 0,+ path_arc_axis: np.ndarray = OUT,+ replace_mobject_with_target_in_scene: bool = False,**kwargs- ):+ ) -> None:self.path_arc = path_arcself.path_func = path_funcself.path_arc_axis = path_arc_axis@@ -58,7 +57,7 @@ class Transform(Animation):super().__init__(mobject, **kwargs)self._init_path_func()- def _init_path_func(self):+ def _init_path_func(self) -> None:if self.path_func is not None:returnelif self.path_arc == 0:@@ -69,7 +68,7 @@ class Transform(Animation):self.path_arc_axis,)- def begin(self):+ def begin(self) -> None:# Use a copy of target_mobject for the align_data# call so that the actual target_mobject stays# preserved.@@ -81,30 +80,30 @@ class Transform(Animation):self.mobject.align_data(self.target_copy)super().begin()- def create_target(self):+ def create_target(self) -> typing.Union[Mobject, None]:# Has no meaningful effect here, but may be useful# in subclassesreturn self.target_mobject- def check_target_mobject_validity(self):+ def check_target_mobject_validity(self) -> None:if self.target_mobject is None:message = "{}.create_target not properly implemented"raise NotImplementedError(message.format(self.__class__.__name__))- def clean_up_from_scene(self, scene):+ def clean_up_from_scene(self, scene: "Scene") -> None:super().clean_up_from_scene(scene)if self.replace_mobject_with_target_in_scene:scene.remove(self.mobject)scene.add(self.target_mobject)- def update_config(self, **kwargs):+ def update_config(self, **kwargs: typing.Dict[str, typing.Any]) -> None:Animation.update_config(self, **kwargs)if "path_arc" in kwargs:self.path_func = path_along_arc(kwargs["path_arc"], kwargs.get("path_arc_axis", OUT))- def get_all_mobjects(self):+ def get_all_mobjects(self) -> typing.List[Mobject]:return [self.mobject,self.starting_mobject,@@ -112,7 +111,7 @@ class Transform(Animation):self.target_copy,]- def get_all_families_zipped(self):+ def get_all_families_zipped(self) -> typing.Iterable[tuple]: # more precise typing?return zip(*[mob.family_members_with_points()@@ -124,13 +123,19 @@ class Transform(Animation):])- def interpolate_submobject(self, submob, start, target_copy, alpha):- submob.interpolate(start, target_copy, alpha, self.path_func)+ def interpolate_submobject(+ self,+ submobject: Mobject,+ starting_sumobject: Mobject,+ target_copy: Mobject,+ alpha: float,+ ) -> "Transform": # doesn't match the parent class?+ submobject.interpolate(starting_sumobject, target_copy, alpha, self.path_func)return selfclass ReplacementTransform(Transform):- def __init__(self, mobject, target_mobject, **kwargs):+ def __init__(self, mobject: Mobject, target_mobject: Mobject, **kwargs) -> None:super().__init__(mobject, target_mobject, replace_mobject_with_target_in_scene=True, **kwargs)@@ -141,29 +146,41 @@ class TransformFromCopy(Transform):Performs a reversed Transform"""- def __init__(self, mobject, target_mobject, **kwargs):+ def __init__(self, mobject: Mobject, target_mobject: Mobject, **kwargs) -> None:super().__init__(target_mobject, mobject, **kwargs)- def interpolate(self, alpha):+ def interpolate(self, alpha: float) -> None:super().interpolate(1 - alpha)class ClockwiseTransform(Transform):- def __init__(self, mobject, target_mobject, path_arc=-np.pi, **kwargs):+ def __init__(+ self,+ mobject: Mobject,+ target_mobject: Mobject,+ path_arc: float = -np.pi,+ **kwargs+ ) -> None:super().__init__(mobject, target_mobject, path_arc=path_arc, **kwargs)class CounterclockwiseTransform(Transform):- def __init__(self, mobject, target_mobject, path_arc=np.pi, **kwargs):+ def __init__(+ self,+ mobject: Mobject,+ target_mobject: Mobject,+ path_arc: float = np.pi,+ **kwargs+ ) -> None:super().__init__(mobject, target_mobject, path_arc=path_arc, **kwargs)class MoveToTarget(Transform):- def __init__(self, mobject, **kwargs):+ def __init__(self, mobject: Mobject, **kwargs) -> None:self.check_validity_of_input(mobject)super().__init__(mobject, mobject.target, **kwargs)- def check_validity_of_input(self, mobject):+ def check_validity_of_input(self, mobject: Mobject) -> None:if not hasattr(mobject, "target"):raise ValueError("MoveToTarget called on mobject" "without attribute 'target'"@@ -171,7 +188,9 @@ class MoveToTarget(Transform):class ApplyMethod(Transform):- def __init__(self, method, *args, **kwargs):+ def __init__(+ self, method: types.MethodType, *args, **kwargs+ ) -> None: # method typing? for args?"""method is a method of Mobject, ``args`` are arguments forthat method. Key word arguments should be passed in@@ -185,7 +204,7 @@ class ApplyMethod(Transform):self.method_args = argssuper().__init__(method.__self__, **kwargs)- def check_validity_of_input(self, method):+ def check_validity_of_input(self, method: types.MethodType) -> None:if not inspect.ismethod(method):raise ValueError("Whoops, looks like you accidentally invoked "@@ -193,7 +212,7 @@ class ApplyMethod(Transform):)assert isinstance(method.__self__, Mobject)- def create_target(self):+ def create_target(self): # what is returned?method = self.method# Make sure it's a list so that args.pop() worksargs = list(self.method_args)@@ -229,47 +248,51 @@ class ApplyPointwiseFunction(ApplyMethod):"""def __init__(- self, function, mobject, run_time=DEFAULT_POINTWISE_FUNCTION_RUN_TIME, **kwargs- ):+ self,+ function: types.MethodType,+ mobject: Mobject,+ run_time: float = DEFAULT_POINTWISE_FUNCTION_RUN_TIME,+ **kwargs+ ) -> None:super().__init__(mobject.apply_function, function, run_time=run_time, **kwargs)class ApplyPointwiseFunctionToCenter(ApplyPointwiseFunction):- def __init__(self, function, mobject, **kwargs):+ def __init__(self, function: types.MethodType, mobject: Mobject, **kwargs) -> None:self.function = functionsuper().__init__(mobject.move_to, **kwargs)- def begin(self):+ def begin(self) -> None:self.method_args = [self.function(self.mobject.get_center())]super().begin()class FadeToColor(ApplyMethod):- def __init__(self, mobject, color, **kwargs):+ def __init__(self, mobject: Mobject, color: str, **kwargs) -> None:super().__init__(mobject.set_color, color, **kwargs)class ScaleInPlace(ApplyMethod):- def __init__(self, mobject, scale_factor, **kwargs):+ def __init__(self, mobject: Mobject, scale_factor: float, **kwargs) -> None:super().__init__(mobject.scale, scale_factor, **kwargs)class ShrinkToCenter(ScaleInPlace):- def __init__(self, mobject, **kwargs):+ def __init__(self, mobject: Mobject, **kwargs) -> None:super().__init__(mobject, 0, **kwargs)class Restore(ApplyMethod):- def __init__(self, mobject, **kwargs):+ def __init__(self, mobject: Mobject, **kwargs) -> None:super().__init__(mobject.restore, **kwargs)class ApplyFunction(Transform):- def __init__(self, function, mobject, **kwargs):+ def __init__(self, function: types.MethodType, mobject: Mobject, **kwargs) -> None:self.function = functionsuper().__init__(mobject, **kwargs)- def create_target(self):+ def create_target(self) -> typing.Any:target = self.function(self.mobject.copy())if not isinstance(target, Mobject):raise TypeError(@@ -279,7 +302,7 @@ class ApplyFunction(Transform):class ApplyMatrix(ApplyPointwiseFunction):- def __init__(self, matrix, mobject, **kwargs):+ def __init__(self, matrix: np.ndarray, mobject: Mobject, **kwargs) -> None:matrix = self.initialize_matrix(matrix)def func(p):@@ -287,7 +310,7 @@ class ApplyMatrix(ApplyPointwiseFunction):super().__init__(func, mobject, **kwargs)- def initialize_matrix(self, matrix):+ def initialize_matrix(self, matrix: np.ndarray) -> np.ndarray:matrix = np.array(matrix)if matrix.shape == (2, 2):new_matrix = np.identity(3)@@ -299,12 +322,12 @@ class ApplyMatrix(ApplyPointwiseFunction):class ApplyComplexFunction(ApplyMethod):- def __init__(self, function, mobject, **kwargs):+ def __init__(self, function: types.MethodType, mobject: Mobject, **kwargs) -> None:self.function = functionmethod = mobject.apply_complex_functionsuper().__init__(method, function, **kwargs)- def _init_path_func(self):+ def _init_path_func(self) -> None:func1 = self.function(complex(1))self.path_arc = np.log(func1).imagsuper()._init_path_func()@@ -314,11 +337,13 @@ class ApplyComplexFunction(ApplyMethod):class CyclicReplace(Transform):- def __init__(self, *mobjects, path_arc=90 * DEGREES, **kwargs):+ def __init__(+ self, *mobjects: Mobject, path_arc: float = 90 * DEGREES, **kwargs+ ) -> None:self.group = Group(*mobjects)super().__init__(self.group, path_arc=path_arc, **kwargs)- def create_target(self):+ def create_target(self) -> Group:target = self.group.copy()cycled_targets = [target[-1], *target[:-1]]for m1, m2 in zip(cycled_targets, self.group):@@ -333,8 +358,12 @@ class Swap(CyclicReplace):# TODO, this may be depricated...worth reimplementing?class TransformAnimations(Transform):def __init__(- self, start_anim, end_anim, rate_func=squish_rate_func(smooth), **kwargs- ):+ self,+ start_anim: Animation,+ end_anim: Animation,+ rate_func: typing.Callable = squish_rate_func(smooth),+ **kwargs+ ) -> None:self.start_anim = start_animself.end_anim = end_animif "run_time" in kwargs:@@ -360,7 +389,7 @@ class TransformAnimations(Transform):start_anim.mobject = self.starting_mobjectend_anim.mobject = self.target_mobject- def interpolate(self, alpha):+ def interpolate(self, alpha: float) -> None:self.start_anim.interpolate(alpha)self.end_anim.interpolate(alpha)Transform.interpolate(self, alpha)diff --git a/manim/animation/update.py b/manim/animation/update.pyindex 7b6286fa5..d6fb376cc 100644--- a/manim/animation/update.py+++ b/manim/animation/update.py@@ -4,9 +4,13 @@ __all__ = ["UpdateFromFunc", "UpdateFromAlphaFunc", "MaintainPositionRelativeTo"import operator as op+import typingfrom ..animation.animation import Animation+if typing.TYPE_CHECKING:+ from ..mobject.mobject import Mobject+class UpdateFromFunc(Animation):"""@@ -16,24 +20,30 @@ class UpdateFromFunc(Animation):"""def __init__(- self, mobject, update_function, suspend_mobject_updating=False, **kwargs- ):+ self,+ mobject: "Mobject",+ update_function: typing.Callable[["Mobject"], typing.Any],+ suspend_mobject_updating: bool = False,+ **kwargs+ ) -> None:self.update_function = update_functionsuper().__init__(mobject, suspend_mobject_updating=suspend_mobject_updating, **kwargs)- def interpolate_mobject(self, alpha):+ def interpolate_mobject(self, alpha: float) -> None:self.update_function(self.mobject)class UpdateFromAlphaFunc(UpdateFromFunc):- def interpolate_mobject(self, alpha):+ def interpolate_mobject(self, alpha: float) -> None:self.update_function(self.mobject, alpha)class MaintainPositionRelativeTo(Animation):- def __init__(self, mobject, tracked_mobject, **kwargs):+ def __init__(+ self, mobject: "Mobject", tracked_mobject: "Mobject", **kwargs+ ) -> None:self.tracked_mobject = tracked_mobjectself.diff = op.sub(mobject.get_center(),@@ -41,7 +51,7 @@ class MaintainPositionRelativeTo(Animation):)super().__init__(mobject, **kwargs)- def interpolate_mobject(self, alpha):+ def interpolate_mobject(self, alpha: float) -> None:target = self.tracked_mobject.get_center()location = self.mobject.get_center()self.mobject.shift(target - location + self.diff)diff --git a/manim/constants.py b/manim/constants.pyindex e1e8e3064..a51e79985 100644--- a/manim/constants.py+++ b/manim/constants.py@@ -2,124 +2,125 @@Constant definitions."""-import numpy as np+import typing+import numpy as np# Messages-NOT_SETTING_FONT_MSG = """+NOT_SETTING_FONT_MSG: str = """You haven't set font.If you are not using English, this may cause text rendering problem.You set font like:text = Text('your text', font='your font')"""-SCENE_NOT_FOUND_MESSAGE = """+SCENE_NOT_FOUND_MESSAGE: str = """{} is not in the script"""-CHOOSE_NUMBER_MESSAGE = """+CHOOSE_NUMBER_MESSAGE: str = """Choose number corresponding to desired scene/arguments.(Use comma separated list for multiple entries)Choice(s): """-INVALID_NUMBER_MESSAGE = "Invalid scene numbers have been specified. Aborting."-NO_SCENE_MESSAGE = """+INVALID_NUMBER_MESSAGE: str = "Invalid scene numbers have been specified. Aborting."+NO_SCENE_MESSAGE: str = """There are no scenes inside that module"""# Cairo and Pango stuff-NORMAL = "NORMAL"-ITALIC = "ITALIC"-OBLIQUE = "OBLIQUE"-BOLD = "BOLD"+NORMAL: str = "NORMAL"+ITALIC: str = "ITALIC"+OBLIQUE: str = "OBLIQUE"+BOLD: str = "BOLD"# Only for Pango from below-THIN = "THIN"-ULTRALIGHT = "ULTRALIGHT"-LIGHT = "LIGHT"-SEMILIGHT = "SEMILIGHT"-BOOK = "BOOK"-MEDIUM = "MEDIUM"-SEMIBOLD = "SEMIBOLD"-ULTRABOLD = "ULTRABOLD"-HEAVY = "HEAVY"-ULTRAHEAVY = "ULTRAHEAVY"+THIN: str = "THIN"+ULTRALIGHT: str = "ULTRALIGHT"+LIGHT: str = "LIGHT"+SEMILIGHT: str = "SEMILIGHT"+BOOK: str = "BOOK"+MEDIUM: str = "MEDIUM"+SEMIBOLD: str = "SEMIBOLD"+ULTRABOLD: str = "ULTRABOLD"+HEAVY: str = "HEAVY"+ULTRAHEAVY: str = "ULTRAHEAVY"# Geometry: directions-ORIGIN = np.array((0.0, 0.0, 0.0))+ORIGIN: np.ndarray = np.array((0.0, 0.0, 0.0))"""The center of the coordinate system."""-UP = np.array((0.0, 1.0, 0.0))+UP: np.ndarray = np.array((0.0, 1.0, 0.0))"""One unit step in the positive Y direction."""-DOWN = np.array((0.0, -1.0, 0.0))+DOWN: np.ndarray = np.array((0.0, -1.0, 0.0))"""One unit step in the negative Y direction."""-RIGHT = np.array((1.0, 0.0, 0.0))+RIGHT: np.ndarray = np.array((1.0, 0.0, 0.0))"""One unit step in the positive X direction."""-LEFT = np.array((-1.0, 0.0, 0.0))+LEFT: np.ndarray = np.array((-1.0, 0.0, 0.0))"""One unit step in the negative X direction."""-IN = np.array((0.0, 0.0, -1.0))+IN: np.ndarray = np.array((0.0, 0.0, -1.0))"""One unit step in the negative Z direction."""-OUT = np.array((0.0, 0.0, 1.0))+OUT: np.ndarray = np.array((0.0, 0.0, 1.0))"""One unit step in the positive Z direction."""# Geometry: axes-X_AXIS = np.array((1.0, 0.0, 0.0))-Y_AXIS = np.array((0.0, 1.0, 0.0))-Z_AXIS = np.array((0.0, 0.0, 1.0))+X_AXIS: np.ndarray = np.array((1.0, 0.0, 0.0))+Y_AXIS: np.ndarray = np.array((0.0, 1.0, 0.0))+Z_AXIS: np.ndarray = np.array((0.0, 0.0, 1.0))# Geometry: useful abbreviations for diagonals-UL = UP + LEFT+UL: np.ndarray = UP + LEFT"""One step up plus one step left."""-UR = UP + RIGHT+UR: np.ndarray = UP + RIGHT"""One step up plus one step right."""-DL = DOWN + LEFT+DL: np.ndarray = DOWN + LEFT"""One step down plus one step left."""-DR = DOWN + RIGHT+DR: np.ndarray = DOWN + RIGHT"""One step down plus one step right."""# Geometry-START_X = 30-START_Y = 20+START_X: int = 30+START_Y: int = 20# Default buffers (padding)-SMALL_BUFF = 0.1-MED_SMALL_BUFF = 0.25-MED_LARGE_BUFF = 0.5-LARGE_BUFF = 1-DEFAULT_MOBJECT_TO_EDGE_BUFFER = MED_LARGE_BUFF-DEFAULT_MOBJECT_TO_MOBJECT_BUFFER = MED_SMALL_BUFF+SMALL_BUFF: float = 0.1+MED_SMALL_BUFF: float = 0.25+MED_LARGE_BUFF: float = 0.5+LARGE_BUFF: float = 1+DEFAULT_MOBJECT_TO_EDGE_BUFFER: float = MED_LARGE_BUFF+DEFAULT_MOBJECT_TO_MOBJECT_BUFFER: float = MED_SMALL_BUFF# Times in seconds-DEFAULT_POINTWISE_FUNCTION_RUN_TIME = 3.0-DEFAULT_WAIT_TIME = 1.0+DEFAULT_POINTWISE_FUNCTION_RUN_TIME: float = 3.0+DEFAULT_WAIT_TIME: float = 1.0# Misc-DEFAULT_POINT_DENSITY_2D = 25-DEFAULT_POINT_DENSITY_1D = 250-DEFAULT_STROKE_WIDTH = 4+DEFAULT_POINT_DENSITY_2D: int = 25+DEFAULT_POINT_DENSITY_1D: int = 250+DEFAULT_STROKE_WIDTH: int = 4# Mathematical constants-PI = np.pi+PI: float = np.pi"""The ratio of the circumference of a circle to its diameter."""-TAU = 2 * PI+TAU: float = 2 * PI"""The ratio of the circumference of a circle to its radius."""-DEGREES = TAU / 360+DEGREES: float = TAU / 360"""The exchange rate between radians and degrees."""# ffmpeg stuff-FFMPEG_BIN = "ffmpeg"+FFMPEG_BIN: str = "ffmpeg"# gif stuff-GIF_FILE_EXTENSION = ".gif"+GIF_FILE_EXTENSION: str = ".gif"-FFMPEG_VERBOSITY_MAP = {+FFMPEG_VERBOSITY_MAP: typing.Dict[str, str] = {"DEBUG": "error","INFO": "error","WARNING": "error",@@ -127,7 +128,7 @@ FFMPEG_VERBOSITY_MAP = {"CRITICAL": "fatal",}VERBOSITY_CHOICES = FFMPEG_VERBOSITY_MAP.keys()-JS_RENDERER_INFO = (+JS_RENDERER_INFO: str = ("The Electron frontend to Manim is hosted at ""https://github.com/ManimCommunity/manim-renderer. After cloning and building it, ""you can either start it prior to running Manim or specify the path to the "@@ -135,7 +136,7 @@ JS_RENDERER_INFO = ()# Video qualities-QUALITIES = {+QUALITIES: typing.Dict[str, typing.Dict[str, typing.Union[str, int, None]]] = {"fourk_quality": {"flag": "k","pixel_height": 2160,@@ -174,5 +175,5 @@ QUALITIES = {},}-DEFAULT_QUALITY = "high_quality"+DEFAULT_QUALITY: str = "high_quality"DEFAULT_QUALITY_SHORT = QUALITIES[DEFAULT_QUALITY]["flag"]