From 4e745e2457b4365c5d6a83edbd94821d013d8b1f Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 00:01:35 +0200 Subject: [PATCH 01/13] # added new color implementation --- manim/utils/color.py | 206 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 204 insertions(+), 2 deletions(-) diff --git a/manim/utils/color.py b/manim/utils/color.py index cd0726a681..4bf062b05e 100644 --- a/manim/utils/color.py +++ b/manim/utils/color.py @@ -16,21 +16,223 @@ "random_bright_color", "random_color", "get_shaded_rgb", + "DARK_BLUE", + "DARK_BROWN", + "LIGHT_BROWN", + "BLUE_E", + "BLUE_D", + "BLUE_C", + "BLUE_B", + "BLUE_A", + "TEAL_E", + "TEAL_D", + "TEAL_C", + "TEAL_B", + "TEAL_A", + "GREEN_E", + "GREEN_D", + "GREEN_C", + "GREEN_B", + "GREEN_A", + "YELLOW_E", + "YELLOW_D", + "YELLOW_C", + "YELLOW_B", + "YELLOW_A", + "GOLD_E", + "GOLD_D", + "GOLD_C", + "GOLD_B", + "GOLD_A", + "RED_E", + "RED_D", + "RED_C", + "RED_B", + "RED_A", + "MAROON_E", + "MAROON_D", + "MAROON_C", + "MAROON_B", + "MAROON_A", + "PURPLE_E", + "PURPLE_D", + "PURPLE_C", + "PURPLE_B", + "PURPLE_A", + "WHITE", + "BLACK", + "LIGHT_GRAY", + "LIGHT_GREY", + "GRAY", + "GREY", + "DARK_GREY", + "DARK_GRAY", + "DARKER_GREY", + "DARKER_GRAY", + "GREY_BROWN", + "PINK", + "LIGHT_PINK", + "GREEN_SCREEN", + "ORANGE", ] - +from enum import Enum import random from colour import Color import numpy as np from ..constants import COLOR_MAP -from ..constants import WHITE from ..utils.bezier import interpolate from ..utils.simple_functions import clip_in_place from ..utils.space_ops import normalize +class Colors(Enum): + """A list of pre-defined colors. + Examples + -------- + The preferred way of using these colors is + .. code-block:: python + import manim.utils.color as C + C.WHITE # -> '#FFFFFF' + Note this way uses the name of the colors below in UPPERCASE. + Alternatively, you can also import this Enum directly and use its members + directly, through the use of :code:`color.value`. Note this way uses the + name of the colors in lowercase. + .. code-block:: python + from manim.utils.color import Colors + Colors.white.value # -> '#FFFFFF' + """ + + dark_blue = "#236B8E" + dark_brown = "#8B4513" + light_brown = "#CD853F" + blue_e = "#1C758A" + blue_d = "#29ABCA" + blue_c = "#58C4DD" + blue = "#58C4DD" + blue_b = "#9CDCEB" + blue_a = "#C7E9F1" + teal_e = "#49A88F" + teal_d = "#55C1A7" + teal_c = "#5CD0B3" + teal = "#5CD0B3" + teal_b = "#76DDC0" + teal_a = "#ACEAD7" + green_e = "#699C52" + green_d = "#77B05D" + green_c = "#83C167" + green = "#83C167" + green_b = "#A6CF8C" + green_a = "#C9E2AE" + yellow_e = "#E8C11C" + yellow_d = "#F4D345" + yellow_c = "#FFFF00" + yellow = "#FFFF00" + yellow_b = "#FFEA94" + yellow_a = "#FFF1B6" + gold_e = "#C78D46" + gold_d = "#E1A158" + gold_c = "#F0AC5F" + gold = "#F0AC5F" + gold_b = "#F9B775" + gold_a = "#F7C797" + red_e = "#CF5044" + red_d = "#E65A4C" + red_c = "#FC6255" + red = "#FC6255" + red_b = "#FF8080" + red_a = "#F7A1A3" + maroon_e = "#94424F" + maroon_d = "#A24D61" + maroon_c = "#C55F73" + maroon = "#C55F73" + maroon_b = "#EC92AB" + maroon_a = "#ECABC1" + purple_e = "#644172" + purple_d = "#715582" + purple_c = "#9A72AC" + purple = "#9A72AC" + purple_b = "#B189C6" + purple_a = "#CAA3E8" + white = "#FFFFFF" + black = "#000000" + light_gray = "#BBBBBB" + light_grey = "#BBBBBB" + gray = "#888888" + grey = "#888888" + dark_grey = "#444444" + dark_gray = "#444444" + darker_grey = "#222222" + darker_gray = "#222222" + grey_brown = "#736357" + pink = "#D147BD" + light_pink = "#DC75CD" + green_screen = "#00FF00" + orange = "#FF862F" + + +DARK_BLUE = Colors.dark_blue.value +DARK_BROWN = Colors.dark_brown.value +LIGHT_BROWN = Colors.dark_brown.value +BLUE_E = Colors.blue_e.value +BLUE_D = Colors.blue_d.value +BLUE_C = Colors.blue_c.value +BLUE_B = Colors.blue_b.value +BLUE_A = Colors.blue_a.value +TEAL_E = Colors.teal_e.value +TEAL_D = Colors.teal_d.value +TEAL_C = Colors.teal_c.value +TEAL_B = Colors.teal_b.value +TEAL_A = Colors.teal_a.value +GREEN_E = Colors.green_e.value +GREEN_D = Colors.green_d.value +GREEN_C = Colors.green_c.value +GREEN_B = Colors.green_b.value +GREEN_A = Colors.green_a.value +YELLOW_E = Colors.yellow_e.value +YELLOW_D = Colors.yellow_d.value +YELLOW_C = Colors.yellow_c.value +YELLOW_B = Colors.yellow_b.value +YELLOW_A = Colors.yellow_a.value +GOLD_E = Colors.gold_e.value +GOLD_D = Colors.gold_d.value +GOLD_C = Colors.gold_c.value +GOLD_B = Colors.gold_b.value +GOLD_A = Colors.gold_a.value +RED_E = Colors.red_e.value +RED_D = Colors.red_d.value +RED_C = Colors.red_c.value +RED_B = Colors.red_b.value +RED_A = Colors.red_a.value +MAROON_E = Colors.maroon_e.value +MAROON_D = Colors.maroon_d.value +MAROON_C = Colors.maroon_c.value +MAROON_B = Colors.maroon_b.value +MAROON_A = Colors.maroon_a.value +PURPLE_E = Colors.purple_e.value +PURPLE_D = Colors.purple_d.value +PURPLE_C = Colors.purple_c.value +PURPLE_B = Colors.purple_b.value +PURPLE_A = Colors.purple_a.value +WHITE = Colors.white.value +BLACK = Colors.black.value +LIGHT_GRAY = Colors.light_gray.value +LIGHT_GREY = Colors.light_grey.value +GRAY = Colors.gray.value +GREY = Colors.grey.value +DARK_GREY = Colors.dark_grey.value +DARK_GRAY = Colors.dark_gray.value +DARKER_GREY = Colors.darker_gray.value +DARKER_GRAY = Colors.darker_gray.value +GREY_BROWN = Colors.grey_brown.value +PINK = Colors.pink.value +LIGHT_PINK = Colors.light_pink.value +GREEN_SCREEN = Colors.green_screen.value +ORANGE = Colors.orange.value + + def color_to_rgb(color): if isinstance(color, str): return hex_to_rgb(color) From 310d881f5a9a338532222efdc79702012c7b85dc Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 09:18:50 +0200 Subject: [PATCH 02/13] added import statement and fixed missing lines --- manim/__init__.py | 1 + manim/utils/color.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/manim/__init__.py b/manim/__init__.py index dd1bf9c7ea..cfa7c33d77 100644 --- a/manim/__init__.py +++ b/manim/__init__.py @@ -65,6 +65,7 @@ from .utils.bezier import * from .utils.color import * +from .utils import color as color from .utils.config_ops import * from .utils.debug import * from .utils.images import * diff --git a/manim/utils/color.py b/manim/utils/color.py index 4bf062b05e..b0025c5d14 100644 --- a/manim/utils/color.py +++ b/manim/utils/color.py @@ -22,41 +22,49 @@ "BLUE_E", "BLUE_D", "BLUE_C", + "BLUE", "BLUE_B", "BLUE_A", "TEAL_E", "TEAL_D", "TEAL_C", + "TEAL", "TEAL_B", "TEAL_A", "GREEN_E", "GREEN_D", "GREEN_C", + "GREEN", "GREEN_B", "GREEN_A", "YELLOW_E", "YELLOW_D", "YELLOW_C", + "YELLOW", "YELLOW_B", "YELLOW_A", "GOLD_E", "GOLD_D", "GOLD_C", + "GOLD", "GOLD_B", "GOLD_A", "RED_E", "RED_D", "RED_C", + "RED", "RED_B", "RED_A", "MAROON_E", "MAROON_D", "MAROON_C", + "MAROON", "MAROON_B", "MAROON_A", "PURPLE_E", "PURPLE_D", "PURPLE_C", + "PURPLE", "PURPLE_B", "PURPLE_A", "WHITE", @@ -82,7 +90,6 @@ from colour import Color import numpy as np -from ..constants import COLOR_MAP from ..utils.bezier import interpolate from ..utils.simple_functions import clip_in_place from ..utils.space_ops import normalize @@ -179,41 +186,49 @@ class Colors(Enum): BLUE_E = Colors.blue_e.value BLUE_D = Colors.blue_d.value BLUE_C = Colors.blue_c.value +BLUE = Colors.blue.value BLUE_B = Colors.blue_b.value BLUE_A = Colors.blue_a.value TEAL_E = Colors.teal_e.value TEAL_D = Colors.teal_d.value TEAL_C = Colors.teal_c.value +TEAL = Colors.teal.value TEAL_B = Colors.teal_b.value TEAL_A = Colors.teal_a.value GREEN_E = Colors.green_e.value GREEN_D = Colors.green_d.value GREEN_C = Colors.green_c.value +GREEN = Colors.green.value GREEN_B = Colors.green_b.value GREEN_A = Colors.green_a.value YELLOW_E = Colors.yellow_e.value YELLOW_D = Colors.yellow_d.value YELLOW_C = Colors.yellow_c.value +YELLOW = Colors.yellow.value YELLOW_B = Colors.yellow_b.value YELLOW_A = Colors.yellow_a.value GOLD_E = Colors.gold_e.value GOLD_D = Colors.gold_d.value GOLD_C = Colors.gold_c.value +GOLD = Colors.gold.value GOLD_B = Colors.gold_b.value GOLD_A = Colors.gold_a.value RED_E = Colors.red_e.value RED_D = Colors.red_d.value RED_C = Colors.red_c.value +RED = Colors.red.value RED_B = Colors.red_b.value RED_A = Colors.red_a.value MAROON_E = Colors.maroon_e.value MAROON_D = Colors.maroon_d.value MAROON_C = Colors.maroon_c.value +MAROON = Colors.maroon.value MAROON_B = Colors.maroon_b.value MAROON_A = Colors.maroon_a.value PURPLE_E = Colors.purple_e.value PURPLE_D = Colors.purple_d.value PURPLE_C = Colors.purple_c.value +PURPLE = Colors.purple.value PURPLE_B = Colors.purple_b.value PURPLE_A = Colors.purple_a.value WHITE = Colors.white.value @@ -265,7 +280,7 @@ def hex_to_rgb(hex_code): hex_part = hex_code[1:] if len(hex_part) == 3: "".join([2 * c for c in hex_part]) - return np.array([int(hex_part[i : i + 2], 16) / 255 for i in range(0, 6, 2)]) + return np.array([int(hex_part[i: i + 2], 16) / 255 for i in range(0, 6, 2)]) def invert_color(color): @@ -326,4 +341,4 @@ def get_shaded_rgb(rgb, point, unit_normal_vect, light_source): factor *= 0.5 result = rgb + factor clip_in_place(rgb + factor, 0, 1) - return result + return result \ No newline at end of file From e902b20a9a0ac83da6cb14e1034aca30fb4f1178 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 09:39:32 +0200 Subject: [PATCH 03/13] removed colors from config and imported all colors at the needed places manually --- manim/animation/indication.py | 1 + manim/animation/specialized.py | 3 +- manim/camera/camera.py | 2 +- manim/camera/moving_camera.py | 3 +- manim/constants.py | 70 ---------------------- manim/mobject/changing.py | 2 +- manim/mobject/coordinate_systems.py | 2 + manim/mobject/frame.py | 1 + manim/mobject/functions.py | 2 + manim/mobject/geometry.py | 2 +- manim/mobject/matrix.py | 1 + manim/mobject/mobject.py | 2 +- manim/mobject/number_line.py | 1 + manim/mobject/probability.py | 2 +- manim/mobject/shape_matchers.py | 2 +- manim/mobject/svg/code_mobject.py | 2 + manim/mobject/svg/drawings.py | 1 + manim/mobject/svg/tex_mobject.py | 1 + manim/mobject/svg/text_mobject.py | 2 +- manim/mobject/three_dimensions.py | 2 +- manim/mobject/types/image_mobject.py | 2 +- manim/mobject/types/point_cloud_mobject.py | 2 +- manim/mobject/types/vectorized_mobject.py | 2 +- manim/mobject/vector_field.py | 2 +- manim/scene/graph_scene.py | 2 +- manim/scene/vector_space_scene.py | 1 + manim/utils/debug.py | 3 +- 27 files changed, 30 insertions(+), 88 deletions(-) diff --git a/manim/animation/indication.py b/manim/animation/indication.py index 4711b72d3b..cb1bcd0e14 100644 --- a/manim/animation/indication.py +++ b/manim/animation/indication.py @@ -40,6 +40,7 @@ from ..utils.config_ops import digest_config from ..utils.rate_functions import there_and_back from ..utils.rate_functions import wiggle +from ..utils.color import GREY, YELLOW class FocusOn(Transform): diff --git a/manim/animation/specialized.py b/manim/animation/specialized.py index 5cda1068ef..975b60ddcd 100644 --- a/manim/animation/specialized.py +++ b/manim/animation/specialized.py @@ -8,13 +8,12 @@ from ..animation.composition import LaggedStart from ..animation.transform import ApplyMethod from ..animation.transform import Restore -from ..constants import WHITE -from ..constants import BLACK from ..mobject.geometry import Circle from ..mobject.svg.drawings import Car from ..mobject.types.vectorized_mobject import VGroup from ..utils.config_ops import digest_config from ..utils.space_ops import get_norm +from ..utils.color import BLACK, WHITE class MoveCar(ApplyMethod): diff --git a/manim/camera/camera.py b/manim/camera/camera.py index 81c8db9f5b..35592ca290 100644 --- a/manim/camera/camera.py +++ b/manim/camera/camera.py @@ -20,7 +20,7 @@ from ..mobject.mobject import Mobject from ..mobject.types.point_cloud_mobject import PMobject from ..mobject.types.vectorized_mobject import VMobject -from ..utils.color import color_to_int_rgba +from ..utils.color import color_to_int_rgba, BLACK from ..utils.config_ops import digest_config from ..utils.images import get_full_raster_image_path from ..utils.iterables import list_difference_update diff --git a/manim/camera/moving_camera.py b/manim/camera/moving_camera.py index e5d02e4442..f5d649f9e6 100644 --- a/manim/camera/moving_camera.py +++ b/manim/camera/moving_camera.py @@ -11,10 +11,11 @@ from .. import config from ..camera.camera import Camera -from ..constants import ORIGIN, WHITE +from ..constants import ORIGIN from ..mobject.frame import ScreenRectangle from ..mobject.types.vectorized_mobject import VGroup from ..utils.config_ops import digest_config +from ..utils.color import WHITE # TODO, think about how to incorporate perspective diff --git a/manim/constants.py b/manim/constants.py index 1dc6bb5ab8..6263a4680e 100644 --- a/manim/constants.py +++ b/manim/constants.py @@ -112,76 +112,6 @@ class MyText(Text): # gif stuff GIF_FILE_EXTENSION = ".gif" -# Colors -COLOR_MAP = { - "DARK_BLUE": "#236B8E", - "DARK_BROWN": "#8B4513", - "LIGHT_BROWN": "#CD853F", - "BLUE_E": "#1C758A", - "BLUE_D": "#29ABCA", - "BLUE_C": "#58C4DD", - "BLUE_B": "#9CDCEB", - "BLUE_A": "#C7E9F1", - "TEAL_E": "#49A88F", - "TEAL_D": "#55C1A7", - "TEAL_C": "#5CD0B3", - "TEAL_B": "#76DDC0", - "TEAL_A": "#ACEAD7", - "GREEN_E": "#699C52", - "GREEN_D": "#77B05D", - "GREEN_C": "#83C167", - "GREEN_B": "#A6CF8C", - "GREEN_A": "#C9E2AE", - "YELLOW_E": "#E8C11C", - "YELLOW_D": "#F4D345", - "YELLOW_C": "#FFFF00", - "YELLOW_B": "#FFEA94", - "YELLOW_A": "#FFF1B6", - "GOLD_E": "#C78D46", - "GOLD_D": "#E1A158", - "GOLD_C": "#F0AC5F", - "GOLD_B": "#F9B775", - "GOLD_A": "#F7C797", - "RED_E": "#CF5044", - "RED_D": "#E65A4C", - "RED_C": "#FC6255", - "RED_B": "#FF8080", - "RED_A": "#F7A1A3", - "MAROON_E": "#94424F", - "MAROON_D": "#A24D61", - "MAROON_C": "#C55F73", - "MAROON_B": "#EC92AB", - "MAROON_A": "#ECABC1", - "PURPLE_E": "#644172", - "PURPLE_D": "#715582", - "PURPLE_C": "#9A72AC", - "PURPLE_B": "#B189C6", - "PURPLE_A": "#CAA3E8", - "WHITE": "#FFFFFF", - "BLACK": "#000000", - "LIGHT_GRAY": "#BBBBBB", - "LIGHT_GREY": "#BBBBBB", - "GRAY": "#888888", - "GREY": "#888888", - "DARK_GREY": "#444444", - "DARK_GRAY": "#444444", - "DARKER_GREY": "#222222", - "DARKER_GRAY": "#222222", - "GREY_BROWN": "#736357", - "PINK": "#D147BD", - "LIGHT_PINK": "#DC75CD", - "GREEN_SCREEN": "#00FF00", - "ORANGE": "#FF862F", -} -COLOR_MAP.update( - { - name.replace("_C", ""): COLOR_MAP[name] - for name in COLOR_MAP - if name.endswith("_C") - } -) -PALETTE = list(COLOR_MAP.values()) -locals().update(COLOR_MAP) FFMPEG_VERBOSITY_MAP = { "DEBUG": "error", "INFO": "error", diff --git a/manim/mobject/changing.py b/manim/mobject/changing.py index db73ac5660..38eae65bab 100644 --- a/manim/mobject/changing.py +++ b/manim/mobject/changing.py @@ -2,12 +2,12 @@ __all__ = ["AnimatedBoundary", "TracedPath"] - from ..constants import * from ..mobject.types.vectorized_mobject import VMobject from ..mobject.types.vectorized_mobject import VGroup from ..utils.rate_functions import smooth from ..utils.space_ops import get_norm +from ..utils.color import BLUE_D, BLUE_B, BLUE_E, GREY_BROWN, WHITE class AnimatedBoundary(VGroup): diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py index 6fd8fcbd2f..37a1184715 100644 --- a/manim/mobject/coordinate_systems.py +++ b/manim/mobject/coordinate_systems.py @@ -18,6 +18,8 @@ from ..utils.config_ops import merge_dicts_recursively from ..utils.simple_functions import binary_search from ..utils.space_ops import angle_of_vector +from ..utils.color import LIGHT_GREY, WHITE, BLUE_D, BLUE + # TODO: There should be much more code reuse between Axes, NumberPlane and GraphScene diff --git a/manim/mobject/frame.py b/manim/mobject/frame.py index cf975efb83..17f4ce22bc 100644 --- a/manim/mobject/frame.py +++ b/manim/mobject/frame.py @@ -12,6 +12,7 @@ from ..constants import * from ..mobject.geometry import Rectangle from ..utils.config_ops import digest_config +from ..utils.color import BLACK class ScreenRectangle(Rectangle): diff --git a/manim/mobject/functions.py b/manim/mobject/functions.py index 42ab87d61c..3358405df4 100644 --- a/manim/mobject/functions.py +++ b/manim/mobject/functions.py @@ -7,6 +7,8 @@ from ..constants import * from ..mobject.types.vectorized_mobject import VMobject from ..utils.config_ops import digest_config +from ..utils.color import YELLOW + import math diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index f234ff432a..1f6afee437 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -52,7 +52,7 @@ from ..utils.space_ops import get_norm from ..utils.space_ops import normalize from ..utils.space_ops import rotate_vector - +from ..utils.color import RED, WHITE, BLUE DEFAULT_DOT_RADIUS = 0.08 DEFAULT_SMALL_DOT_RADIUS = 0.04 diff --git a/manim/mobject/matrix.py b/manim/mobject/matrix.py index 4da05dab4d..d6e4a7ed1a 100644 --- a/manim/mobject/matrix.py +++ b/manim/mobject/matrix.py @@ -22,6 +22,7 @@ from ..mobject.svg.tex_mobject import Tex from ..mobject.types.vectorized_mobject import VGroup from ..mobject.types.vectorized_mobject import VMobject +from ..utils.color import WHITE VECTOR_LABEL_SCALE_FACTOR = 0.8 diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 8220bc3d65..3b6f6e6e50 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -18,7 +18,7 @@ from .. import config, file_writer_config from ..constants import * from ..container import Container -from ..utils.color import color_gradient +from ..utils.color import color_gradient, WHITE, BLACK, YELLOW_C from ..utils.color import interpolate_color from ..utils.iterables import list_update from ..utils.iterables import remove_list_redundancies diff --git a/manim/mobject/number_line.py b/manim/mobject/number_line.py index 7de1eb3950..3d5935bec5 100644 --- a/manim/mobject/number_line.py +++ b/manim/mobject/number_line.py @@ -16,6 +16,7 @@ from ..utils.config_ops import merge_dicts_recursively from ..utils.simple_functions import fdiv from ..utils.space_ops import normalize +from ..utils.color import LIGHT_GREY class NumberLine(Line): diff --git a/manim/mobject/probability.py b/manim/mobject/probability.py index 2c6132f051..02643aa5ab 100644 --- a/manim/mobject/probability.py +++ b/manim/mobject/probability.py @@ -11,7 +11,7 @@ from ..mobject.svg.tex_mobject import MathTex from ..mobject.svg.tex_mobject import Tex from ..mobject.types.vectorized_mobject import VGroup -from ..utils.color import color_gradient +from ..utils.color import color_gradient, DARK_GREY, LIGHT_GREY, GREEN_E, BLUE_E, MAROON_B, YELLOW, BLUE from ..utils.iterables import tuplify EPSILON = 0.0001 diff --git a/manim/mobject/shape_matchers.py b/manim/mobject/shape_matchers.py index a3cc7ad922..a9bf1e0cb8 100644 --- a/manim/mobject/shape_matchers.py +++ b/manim/mobject/shape_matchers.py @@ -8,7 +8,7 @@ from ..mobject.geometry import Rectangle from ..mobject.types.vectorized_mobject import VGroup from ..mobject.types.vectorized_mobject import VMobject -from ..utils.color import Color +from ..utils.color import Color, YELLOW, BLACK, RED from ..utils.config_ops import digest_config diff --git a/manim/mobject/svg/code_mobject.py b/manim/mobject/svg/code_mobject.py index 00732fed90..86a98e6a2b 100644 --- a/manim/mobject/svg/code_mobject.py +++ b/manim/mobject/svg/code_mobject.py @@ -21,6 +21,8 @@ from pygments.formatters.html import HtmlFormatter from pygments.styles import get_all_styles +from ...utils.color import WHITE + class Code(VGroup): """A highlighted source code listing. diff --git a/manim/mobject/svg/drawings.py b/manim/mobject/svg/drawings.py index 070186fd7f..2eeaacbbe0 100644 --- a/manim/mobject/svg/drawings.py +++ b/manim/mobject/svg/drawings.py @@ -55,6 +55,7 @@ from ...utils.space_ops import angle_of_vector from ...utils.space_ops import complex_to_R3 from ...utils.space_ops import rotate_vector +from ...utils.color import YELLOW, WHITE, DARK_GREY, MAROON_B, PURPLE, GREEN, BLACK, LIGHT_GREY, GREY, BLUE_B, BLUE_D class Lightbulb(SVGMobject): diff --git a/manim/mobject/svg/tex_mobject.py b/manim/mobject/svg/tex_mobject.py index 4f29530e8c..9cb359740f 100644 --- a/manim/mobject/svg/tex_mobject.py +++ b/manim/mobject/svg/tex_mobject.py @@ -26,6 +26,7 @@ from ...utils.config_ops import digest_config from ...utils.strings import split_string_list_to_isolate_substrings from ...utils.tex_file_writing import tex_to_svg_file +from ...utils.color import BLACK TEX_MOB_SCALE_FACTOR = 0.05 diff --git a/manim/mobject/svg/text_mobject.py b/manim/mobject/svg/text_mobject.py index 6116fe3e90..8e69b37f63 100644 --- a/manim/mobject/svg/text_mobject.py +++ b/manim/mobject/svg/text_mobject.py @@ -16,7 +16,7 @@ from ...mobject.svg.svg_mobject import SVGMobject from ...mobject.types.vectorized_mobject import VGroup from ...utils.config_ops import digest_config - +from ...utils.color import WHITE, BLACK TEXT_MOB_SCALE_FACTOR = 0.05 diff --git a/manim/mobject/three_dimensions.py b/manim/mobject/three_dimensions.py index ffb65f7a50..748f737c49 100644 --- a/manim/mobject/three_dimensions.py +++ b/manim/mobject/three_dimensions.py @@ -2,13 +2,13 @@ __all__ = ["ThreeDVMobject", "ParametricSurface", "Sphere", "Cube", "Prism"] - from ..constants import * from ..mobject.geometry import Square from ..mobject.types.vectorized_mobject import VGroup from ..mobject.types.vectorized_mobject import VMobject from ..utils.iterables import tuplify from ..utils.space_ops import z_to_vector +from ..utils.color import BLUE_D, BLUE , BLUE_E , LIGHT_GREY ############## diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.py index b1e32357b1..a4e11136de 100644 --- a/manim/mobject/types/image_mobject.py +++ b/manim/mobject/types/image_mobject.py @@ -11,7 +11,7 @@ from ...mobject.mobject import Mobject from ...mobject.shape_matchers import SurroundingRectangle from ...utils.bezier import interpolate -from ...utils.color import color_to_int_rgb +from ...utils.color import color_to_int_rgb, WHITE from ...utils.config_ops import digest_config from ...utils.images import get_full_raster_image_path diff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.py index d94c53dd3d..6c5be357cb 100644 --- a/manim/mobject/types/point_cloud_mobject.py +++ b/manim/mobject/types/point_cloud_mobject.py @@ -6,7 +6,7 @@ from ...constants import * from ...mobject.mobject import Mobject from ...utils.bezier import interpolate -from ...utils.color import color_gradient +from ...utils.color import color_gradient, YELLOW_C, WHITE, BLACK, YELLOW from ...utils.color import color_to_rgba from ...utils.color import rgba_to_color from ...utils.config_ops import digest_config diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index dfc5ca409b..cbc63d9c85 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -24,7 +24,7 @@ from ...utils.bezier import interpolate from ...utils.bezier import integer_interpolate from ...utils.bezier import partial_bezier_points -from ...utils.color import color_to_rgba +from ...utils.color import color_to_rgba, BLACK, WHITE from ...utils.iterables import make_even from ...utils.iterables import stretch_array_to_length from ...utils.iterables import tuplify diff --git a/manim/mobject/vector_field.py b/manim/mobject/vector_field.py index 0a41e74785..7ac3e439dd 100644 --- a/manim/mobject/vector_field.py +++ b/manim/mobject/vector_field.py @@ -29,7 +29,7 @@ from ..mobject.types.vectorized_mobject import VMobject from ..utils.bezier import inverse_interpolate from ..utils.bezier import interpolate -from ..utils.color import color_to_rgb +from ..utils.color import color_to_rgb, BLUE_E, GREEN, YELLOW, RED, BLUE, WHITE from ..utils.color import rgb_to_color from ..utils.config_ops import digest_config from ..utils.rate_functions import linear diff --git a/manim/scene/graph_scene.py b/manim/scene/graph_scene.py index 7abf24c870..97313e08f5 100644 --- a/manim/scene/graph_scene.py +++ b/manim/scene/graph_scene.py @@ -21,7 +21,7 @@ from ..mobject.types.vectorized_mobject import VectorizedPoint from ..scene.scene import Scene from ..utils.bezier import interpolate -from ..utils.color import color_gradient +from ..utils.color import color_gradient, GREY, BLUE, GREEN, YELLOW, BLACK, WHITE from ..utils.color import invert_color from ..utils.space_ops import angle_of_vector diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py index 8214f9d1c9..5d0f187201 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -31,6 +31,7 @@ from ..mobject.types.vectorized_mobject import VGroup from ..mobject.types.vectorized_mobject import VMobject from ..scene.scene import Scene +from ..utils.color import GREEN_C, RED_C, BLUE_D, WHITE, YELLOW, GREY, LIGHT_GREY from ..utils.rate_functions import rush_from from ..utils.rate_functions import rush_into from ..utils.space_ops import angle_of_vector diff --git a/manim/utils/debug.py b/manim/utils/debug.py index f02f26e7bd..5ee34fce66 100644 --- a/manim/utils/debug.py +++ b/manim/utils/debug.py @@ -2,8 +2,7 @@ __all__ = ["print_family", "get_submobject_index_labels"] - -from ..constants import BLACK +from .color import BLACK from ..mobject.numbers import Integer from ..mobject.types.vectorized_mobject import VGroup From 345f6fa2092f68cf0fa30d2ff4cdab568ed5fe6c Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 09:50:51 +0200 Subject: [PATCH 04/13] #added random_color --- manim/utils/color.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manim/utils/color.py b/manim/utils/color.py index b0025c5d14..04cbe2cbf0 100644 --- a/manim/utils/color.py +++ b/manim/utils/color.py @@ -331,8 +331,9 @@ def random_bright_color(): def random_color(): - return random.choice(list(COLOR_MAP.values())) - + import time + random.seed(time.time()) + return random.choice([c.value for c in list(Colors)]) def get_shaded_rgb(rgb, point, unit_normal_vect, light_source): to_sun = normalize(light_source - point) From 7dee3ba1b0cfaf535b198b3dbf0de47c42def505 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 09:52:14 +0200 Subject: [PATCH 05/13] # run black everywhere --- logo/logo.py | 16 +-- manim/animation/composition.py | 12 +- manim/animation/creation.py | 13 +- manim/animation/fading.py | 40 ++----- manim/animation/growing.py | 8 +- manim/animation/indication.py | 51 ++------ manim/animation/movement.py | 15 +-- manim/animation/numbers.py | 4 +- manim/animation/rotation.py | 5 +- manim/animation/specialized.py | 18 +-- manim/animation/transform.py | 19 +-- manim/animation/update.py | 9 +- manim/camera/mapping_camera.py | 9 +- manim/camera/moving_camera.py | 7 +- manim/camera/multi_camera.py | 4 +- manim/config/config_utils.py | 61 ++-------- manim/mobject/changing.py | 2 +- manim/mobject/coordinate_systems.py | 43 ++----- manim/mobject/frame.py | 8 +- manim/mobject/functions.py | 6 +- manim/mobject/geometry.py | 81 +++---------- manim/mobject/matrix.py | 8 +- manim/mobject/mobject.py | 17 +-- manim/mobject/number_line.py | 28 ++--- manim/mobject/numbers.py | 10 +- manim/mobject/probability.py | 11 +- manim/mobject/shape_matchers.py | 18 +-- manim/mobject/svg/brace.py | 5 +- manim/mobject/svg/code_mobject.py | 6 +- manim/mobject/svg/drawings.py | 131 ++++++--------------- manim/mobject/svg/tex_mobject.py | 12 +- manim/mobject/svg/text_mobject.py | 9 +- manim/mobject/three_d_shading_utils.py | 8 +- manim/mobject/three_d_utils.py | 8 +- manim/mobject/three_dimensions.py | 19 +-- manim/mobject/types/image_mobject.py | 18 +-- manim/mobject/types/point_cloud_mobject.py | 22 +--- manim/mobject/types/vectorized_mobject.py | 36 ++---- manim/mobject/vector_field.py | 20 +--- manim/scene/reconfigurable_scene.py | 4 +- manim/scene/scene.py | 16 +-- manim/scene/scene_file_writer.py | 36 ++---- manim/scene/vector_space_scene.py | 16 +-- manim/scene/zoomed_scene.py | 5 +- manim/utils/color.py | 8 +- manim/utils/paths.py | 7 +- manim/utils/rate_functions.py | 6 +- manim/utils/sounds.py | 8 +- tests/helpers/video_utils.py | 10 +- tests/test_family.py | 12 +- tests/test_logging/basic_scenes.py | 4 +- tests/utils/GraphicalUnitTester.py | 7 +- tests/utils/commands.py | 5 +- 53 files changed, 222 insertions(+), 739 deletions(-) diff --git a/logo/logo.py b/logo/logo.py index 235b6c6081..d9b77f379b 100644 --- a/logo/logo.py +++ b/logo/logo.py @@ -4,10 +4,7 @@ class Thumbnail(GraphScene): - CONFIG = { - "y_max": 8, - "y_axis_height": 5, - } + CONFIG = {"y_max": 8, "y_axis_height": 5} def construct(self): self.show_function_graph() @@ -98,7 +95,7 @@ def get_h_line(input_tracker): graph_dot_p2.move_to(get_graph_point(input_tracker_p2)) # - self.play(ShowCreation(graph),) + self.play(ShowCreation(graph)) # Animacion del punto a self.add_foreground_mobject(graph_dot_p1) self.add_foreground_mobject(graph_dot_p2) @@ -150,16 +147,11 @@ def get_h_line(input_tracker): ) self.add( - input_triangle_p2, graph_dot_p2, v_line_p2, h_line_p2, output_triangle_p2, + input_triangle_p2, graph_dot_p2, v_line_p2, h_line_p2, output_triangle_p2 ) self.play(FadeIn(grupo_secante)) - kwargs = { - "x_min": 4, - "x_max": 9, - "fill_opacity": 0.75, - "stroke_width": 0.25, - } + kwargs = {"x_min": 4, "x_max": 9, "fill_opacity": 0.75, "stroke_width": 0.25} self.graph = graph iteraciones = 6 diff --git a/manim/animation/composition.py b/manim/animation/composition.py index 21ef0845e0..30cca2a3ea 100644 --- a/manim/animation/composition.py +++ b/manim/animation/composition.py @@ -100,9 +100,7 @@ def interpolate(self, alpha): class Succession(AnimationGroup): - CONFIG = { - "lag_ratio": 1, - } + CONFIG = {"lag_ratio": 1} def begin(self): assert len(self.animations) > 0 @@ -127,15 +125,11 @@ def interpolate(self, alpha): class LaggedStart(AnimationGroup): - CONFIG = { - "lag_ratio": DEFAULT_LAGGED_START_LAG_RATIO, - } + CONFIG = {"lag_ratio": DEFAULT_LAGGED_START_LAG_RATIO} class LaggedStartMap(LaggedStart): - CONFIG = { - "run_time": 2, - } + CONFIG = {"run_time": 2} def __init__(self, AnimationClass, mobject, arg_creator=None, **kwargs): args_list = [] diff --git a/manim/animation/creation.py b/manim/animation/creation.py index ef67b0eb9b..065053f883 100644 --- a/manim/animation/creation.py +++ b/manim/animation/creation.py @@ -41,9 +41,7 @@ def get_bounds(self, alpha): class ShowCreation(ShowPartial): - CONFIG = { - "lag_ratio": 1, - } + CONFIG = {"lag_ratio": 1} def get_bounds(self, alpha): return (0, alpha) @@ -127,10 +125,7 @@ def set_default_config_from_length(self, mobject): class ShowIncreasingSubsets(Animation): - CONFIG = { - "suspend_mobject_updating": False, - "int_func": np.floor, - } + CONFIG = {"suspend_mobject_updating": False, "int_func": np.floor} def __init__(self, group, **kwargs): self.all_submobs = list(group.submobjects) @@ -167,9 +162,7 @@ def __init__(self, text, **kwargs): class ShowSubmobjectsOneByOne(ShowIncreasingSubsets): - CONFIG = { - "int_func": np.ceil, - } + CONFIG = {"int_func": np.ceil} def __init__(self, group, **kwargs): new_group = Group(*group) diff --git a/manim/animation/fading.py b/manim/animation/fading.py index 1e485435ce..85232a4aee 100644 --- a/manim/animation/fading.py +++ b/manim/animation/fading.py @@ -30,10 +30,7 @@ class FadeOut(Transform): - CONFIG = { - "remover": True, - "lag_ratio": DEFAULT_FADE_LAG_RATIO, - } + CONFIG = {"remover": True, "lag_ratio": DEFAULT_FADE_LAG_RATIO} def create_target(self): return self.mobject.copy().fade(1) @@ -44,9 +41,7 @@ def clean_up_from_scene(self, scene=None): class FadeIn(Transform): - CONFIG = { - "lag_ratio": DEFAULT_FADE_LAG_RATIO, - } + CONFIG = {"lag_ratio": DEFAULT_FADE_LAG_RATIO} def create_target(self): return self.mobject @@ -61,10 +56,7 @@ def create_starting_mobject(self): class FadeInFrom(Transform): - CONFIG = { - "direction": DOWN, - "lag_ratio": DEFAULT_ANIMATION_LAG_RATIO, - } + CONFIG = {"direction": DOWN, "lag_ratio": DEFAULT_ANIMATION_LAG_RATIO} def __init__(self, mobject, direction=None, **kwargs): if direction is not None: @@ -86,10 +78,7 @@ class FadeInFromDown(FadeInFrom): communicates the default """ - CONFIG = { - "direction": DOWN, - "lag_ratio": DEFAULT_ANIMATION_LAG_RATIO, - } + CONFIG = {"direction": DOWN, "lag_ratio": DEFAULT_ANIMATION_LAG_RATIO} def __init__(self, mobject, **kwargs): super().__init__(mobject, direction=DOWN, **kwargs) @@ -99,9 +88,7 @@ def __init__(self, mobject, **kwargs): class FadeOutAndShift(FadeOut): - CONFIG = { - "direction": DOWN, - } + CONFIG = {"direction": DOWN} def __init__(self, mobject, direction=None, **kwargs): if direction is not None: @@ -120,9 +107,7 @@ class FadeOutAndShiftDown(FadeOutAndShift): communicates the default """ - CONFIG = { - "direction": DOWN, - } + CONFIG = {"direction": DOWN} def __init__(self, mobject, **kwargs): super().__init__(mobject, direction=DOWN, **kwargs) @@ -144,9 +129,7 @@ def create_starting_mobject(self): class FadeInFromLarge(FadeIn): - CONFIG = { - "scale_factor": 2, - } + CONFIG = {"scale_factor": 2} def __init__(self, mobject, scale_factor=2, **kwargs): if scale_factor is not None: @@ -164,9 +147,7 @@ class VFadeIn(Animation): VFadeIn and VFadeOut only work for VMobjects, """ - CONFIG = { - "suspend_mobject_updating": False, - } + CONFIG = {"suspend_mobject_updating": False} def interpolate_submobject(self, submob, start, alpha): submob.set_stroke(opacity=interpolate(0, start.get_stroke_opacity(), alpha)) @@ -181,7 +162,4 @@ def interpolate_submobject(self, submob, start, alpha): class VFadeInThenOut(VFadeIn): - CONFIG = { - "rate_func": there_and_back, - "remover": True, - } + CONFIG = {"rate_func": there_and_back, "remover": True} diff --git a/manim/animation/growing.py b/manim/animation/growing.py index 62fbee89e0..0d2bcf873a 100644 --- a/manim/animation/growing.py +++ b/manim/animation/growing.py @@ -14,9 +14,7 @@ class GrowFromPoint(Transform): - CONFIG = { - "point_color": None, - } + CONFIG = {"point_color": None} def __init__(self, mobject, point, **kwargs): self.point = point @@ -53,6 +51,4 @@ def __init__(self, arrow, **kwargs): class SpinInFromNothing(GrowFromCenter): - CONFIG = { - "path_arc": PI, - } + CONFIG = {"path_arc": PI} diff --git a/manim/animation/indication.py b/manim/animation/indication.py index cb1bcd0e14..97fd032218 100644 --- a/manim/animation/indication.py +++ b/manim/animation/indication.py @@ -44,12 +44,7 @@ class FocusOn(Transform): - CONFIG = { - "opacity": 0.2, - "color": GREY, - "run_time": 2, - "remover": True, - } + CONFIG = {"opacity": 0.2, "color": GREY, "run_time": 2, "remover": True} def __init__(self, focus_point, **kwargs): self.focus_point = focus_point @@ -73,11 +68,7 @@ def create_starting_mobject(self): class Indicate(Transform): - CONFIG = { - "rate_func": there_and_back, - "scale_factor": 1.2, - "color": YELLOW, - } + CONFIG = {"rate_func": there_and_back, "scale_factor": 1.2, "color": YELLOW} def create_target(self): target = self.mobject.copy() @@ -101,11 +92,7 @@ def __init__(self, point, color=YELLOW, **kwargs): digest_config(self, kwargs) self.lines = self.create_lines() animations = self.create_line_anims() - super().__init__( - *animations, - group=self.lines, - **kwargs, - ) + super().__init__(*animations, group=self.lines, **kwargs) def create_lines(self): lines = VGroup() @@ -127,9 +114,7 @@ class CircleIndicate(Indicate): CONFIG = { "rate_func": there_and_back, "remover": True, - "circle_config": { - "color": YELLOW, - }, + "circle_config": {"color": YELLOW}, } def __init__(self, mobject, **kwargs): @@ -148,10 +133,7 @@ def interpolate_mobject(self, alpha): class ShowPassingFlash(ShowPartial): - CONFIG = { - "time_width": 0.1, - "remover": True, - } + CONFIG = {"time_width": 0.1, "remover": True} def get_bounds(self, alpha): tw = self.time_width @@ -168,16 +150,11 @@ def finish(self): class ShowCreationThenDestruction(ShowPassingFlash): - CONFIG = { - "time_width": 2.0, - "run_time": 1, - } + CONFIG = {"time_width": 2.0, "run_time": 1} class ShowCreationThenFadeOut(Succession): - CONFIG = { - "remover": True, - } + CONFIG = {"remover": True} def __init__(self, mobject, **kwargs): super().__init__(ShowCreation(mobject), FadeOut(mobject), **kwargs) @@ -201,9 +178,7 @@ def __init__(self, mobject, **kwargs): rect = self.get_rect() rect.add_updater(lambda r: r.move_to(mobject)) - super().__init__( - self.rect_animation(rect, **kwargs), - ) + super().__init__(self.rect_animation(rect, **kwargs)) def get_rect(self): return SurroundingRectangle( @@ -224,11 +199,7 @@ class ShowCreationThenFadeAround(AnimationOnSurroundingRectangle): class ApplyWave(Homotopy): - CONFIG = { - "direction": UP, - "amplitude": 0.2, - "run_time": 1, - } + CONFIG = {"direction": UP, "amplitude": 0.2, "run_time": 1} def __init__(self, mobject, **kwargs): digest_config(self, kwargs, locals()) @@ -276,9 +247,7 @@ def interpolate_submobject(self, submobject, starting_sumobject, alpha): class TurnInsideOut(Transform): - CONFIG = { - "path_arc": TAU / 4, - } + CONFIG = {"path_arc": TAU / 4} def create_target(self): return self.mobject.copy().reverse_points() diff --git a/manim/animation/movement.py b/manim/animation/movement.py index 34268237cd..5fec3192d1 100644 --- a/manim/animation/movement.py +++ b/manim/animation/movement.py @@ -14,10 +14,7 @@ class Homotopy(Animation): - CONFIG = { - "run_time": 3, - "apply_function_kwargs": {}, - } + CONFIG = {"run_time": 3, "apply_function_kwargs": {}} def __init__(self, homotopy, mobject, **kwargs): """ @@ -57,11 +54,7 @@ def homotopy(x, y, z, t): class PhaseFlow(Animation): - CONFIG = { - "virtual_time": 1, - "rate_func": linear, - "suspend_mobject_updating": False, - } + CONFIG = {"virtual_time": 1, "rate_func": linear, "suspend_mobject_updating": False} def __init__(self, function, mobject, **kwargs): self.function = function @@ -75,9 +68,7 @@ def interpolate_mobject(self, alpha): class MoveAlongPath(Animation): - CONFIG = { - "suspend_mobject_updating": False, - } + CONFIG = {"suspend_mobject_updating": False} def __init__(self, mobject, path, **kwargs): self.path = path diff --git a/manim/animation/numbers.py b/manim/animation/numbers.py index 1af261eb1e..e55c50a614 100644 --- a/manim/animation/numbers.py +++ b/manim/animation/numbers.py @@ -11,9 +11,7 @@ class ChangingDecimal(Animation): - CONFIG = { - "suspend_mobject_updating": False, - } + CONFIG = {"suspend_mobject_updating": False} def __init__(self, decimal_mob, number_update_func, **kwargs): self.check_validity_of_input(decimal_mob) diff --git a/manim/animation/rotation.py b/manim/animation/rotation.py index 38704f903a..69cdb61c8d 100644 --- a/manim/animation/rotation.py +++ b/manim/animation/rotation.py @@ -32,10 +32,7 @@ def interpolate_mobject(self, alpha): class Rotate(Transform): - CONFIG = { - "about_point": None, - "about_edge": None, - } + CONFIG = {"about_point": None, "about_edge": None} def __init__(self, mobject, angle=PI, axis=OUT, **kwargs): if "path_arc" not in kwargs: diff --git a/manim/animation/specialized.py b/manim/animation/specialized.py index 975b60ddcd..478c9a43ba 100644 --- a/manim/animation/specialized.py +++ b/manim/animation/specialized.py @@ -13,14 +13,11 @@ from ..mobject.types.vectorized_mobject import VGroup from ..utils.config_ops import digest_config from ..utils.space_ops import get_norm -from ..utils.color import BLACK, WHITE +from ..utils.color import BLACK, WHITE class MoveCar(ApplyMethod): - CONFIG = { - "moving_forward": True, - "run_time": 5, - } + CONFIG = {"moving_forward": True, "run_time": 5} def __init__(self, car, target_point, **kwargs): self.check_if_input_is_car(car) @@ -35,10 +32,7 @@ def begin(self): super().begin() car = self.mobject distance = get_norm( - op.sub( - self.target_mobject.get_right(), - self.starting_mobject.get_right(), - ) + op.sub(self.target_mobject.get_right(), self.starting_mobject.get_right()) ) if not self.moving_forward: distance *= -1 @@ -71,11 +65,7 @@ def __init__(self, focal_point, **kwargs): digest_config(self, kwargs) circles = VGroup() for x in range(self.n_circles): - circle = Circle( - radius=self.big_radius, - stroke_color=BLACK, - stroke_width=0, - ) + circle = Circle(radius=self.big_radius, stroke_color=BLACK, stroke_width=0) circle.add_updater(lambda c: c.move_to(focal_point)) circle.save_state() circle.set_width(self.small_radius * 2) diff --git a/manim/animation/transform.py b/manim/animation/transform.py index 43cd7ac9f5..dc5a560e64 100644 --- a/manim/animation/transform.py +++ b/manim/animation/transform.py @@ -59,10 +59,7 @@ def init_path_func(self): elif self.path_arc == 0: self.path_func = straight_path else: - self.path_func = path_along_arc( - self.path_arc, - self.path_arc_axis, - ) + self.path_func = path_along_arc(self.path_arc, self.path_arc_axis) def begin(self): # Use a copy of target_mobject for the align_data @@ -111,11 +108,7 @@ def get_all_families_zipped(self): return zip( *[ mob.family_members_with_points() - for mob in [ - self.mobject, - self.starting_mobject, - self.target_copy, - ] + for mob in [self.mobject, self.starting_mobject, self.target_copy] ] ) @@ -125,9 +118,7 @@ def interpolate_submobject(self, submob, start, target_copy, alpha): class ReplacementTransform(Transform): - CONFIG = { - "replace_mobject_with_target_in_scene": True, - } + CONFIG = {"replace_mobject_with_target_in_scene": True} class TransformFromCopy(Transform): @@ -286,9 +277,7 @@ def init_path_func(self): class CyclicReplace(Transform): - CONFIG = { - "path_arc": 90 * DEGREES, - } + CONFIG = {"path_arc": 90 * DEGREES} def __init__(self, *mobjects, **kwargs): self.group = Group(*mobjects) diff --git a/manim/animation/update.py b/manim/animation/update.py index 11934a6dbb..479e0a7fb6 100644 --- a/manim/animation/update.py +++ b/manim/animation/update.py @@ -15,9 +15,7 @@ class UpdateFromFunc(Animation): on another simultaneously animated mobject """ - CONFIG = { - "suspend_mobject_updating": False, - } + CONFIG = {"suspend_mobject_updating": False} def __init__(self, mobject, update_function, **kwargs): self.update_function = update_function @@ -35,10 +33,7 @@ def interpolate_mobject(self, alpha): class MaintainPositionRelativeTo(Animation): def __init__(self, mobject, tracked_mobject, **kwargs): self.tracked_mobject = tracked_mobject - self.diff = op.sub( - mobject.get_center(), - tracked_mobject.get_center(), - ) + self.diff = op.sub(mobject.get_center(), tracked_mobject.get_center()) super().__init__(mobject, **kwargs) def interpolate_mobject(self, alpha): diff --git a/manim/camera/mapping_camera.py b/manim/camera/mapping_camera.py index 124ed8b741..2611d70f88 100644 --- a/manim/camera/mapping_camera.py +++ b/manim/camera/mapping_camera.py @@ -43,10 +43,7 @@ def capture_mobjects(self, mobjects, **kwargs): ): mobject.insert_n_curves(self.min_num_curves) Camera.capture_mobjects( - self, - mobject_copies, - include_submobjects=False, - excluded_mobjects=None, + self, mobject_copies, include_submobjects=False, excluded_mobjects=None ) @@ -127,7 +124,5 @@ def __init__(self, left_camera, right_camera, **kwargs): camera.reset_pixel_shape(camera.pixel_height, half_width) OldMultiCamera.__init__( - self, - (left_camera, (0, 0)), - (right_camera, (0, half_width)), + self, (left_camera, (0, 0)), (right_camera, (0, half_width)) ) diff --git a/manim/camera/moving_camera.py b/manim/camera/moving_camera.py index f5d649f9e6..b5e0d97e54 100644 --- a/manim/camera/moving_camera.py +++ b/manim/camera/moving_camera.py @@ -20,9 +20,7 @@ # TODO, think about how to incorporate perspective class CameraFrame(VGroup): - CONFIG = { - "center": ORIGIN, - } + CONFIG = {"center": ORIGIN} def __init__(self, **kwargs): VGroup.__init__(self, **kwargs) @@ -55,8 +53,7 @@ def __init__(self, frame=None, **kwargs): if frame is None: frame = ScreenRectangle(height=config["frame_height"]) frame.set_stroke( - self.default_frame_stroke_color, - self.default_frame_stroke_width, + self.default_frame_stroke_color, self.default_frame_stroke_width ) self.frame = frame Camera.__init__(self, **kwargs) diff --git a/manim/camera/multi_camera.py b/manim/camera/multi_camera.py index a503a849a8..1e4a640fe3 100644 --- a/manim/camera/multi_camera.py +++ b/manim/camera/multi_camera.py @@ -10,9 +10,7 @@ class MultiCamera(MovingCamera): """Camera Object that allows for multiple perspectives.""" - CONFIG = { - "allow_cameras_to_capture_their_own_display": False, - } + CONFIG = {"allow_cameras_to_capture_their_own_display": False} def __init__(self, *image_mobjects_from_cameras, **kwargs): """Initalises the MultiCamera diff --git a/manim/config/config_utils.py b/manim/config/config_utils.py index 9ec4ca8a68..685485d795 100644 --- a/manim/config/config_utils.py +++ b/manim/config/config_utils.py @@ -200,8 +200,7 @@ def _parse_cli(arg_list, input=True): if only_manim or not _subcommand_name(ignore=["--help", "-h"]): parser.add_argument( - "file", - help="path to file holding the python code for the scene", + "file", help="path to file holding the python code for the scene" ) parser.add_argument( "scene_names", @@ -237,10 +236,7 @@ def _parse_cli(arg_list, input=True): help="Show the output file in the File Browser", ) parser.add_argument( - "--sound", - action="store_const", - const=True, - help="Play a success/failure sound", + "--sound", action="store_const", const=True, help="Play a success/failure sound" ) parser.add_argument( "--leave_progress_bars", @@ -302,27 +298,13 @@ def _parse_cli(arg_list, input=True): help="Log terminal output to file", ) # The default value of the following is set in manim.cfg + parser.add_argument("-c", "--background_color", help="Specify background color") + parser.add_argument("--background_opacity", help="Specify background opacity") parser.add_argument( - "-c", - "--background_color", - help="Specify background color", - ) - parser.add_argument( - "--background_opacity", - help="Specify background opacity", - ) - parser.add_argument( - "--media_dir", - help="Directory to store media (including video files)", - ) - parser.add_argument( - "--log_dir", - help="Directory to store log files", - ) - parser.add_argument( - "--tex_template", - help="Specify a custom TeX template file", + "--media_dir", help="Directory to store media (including video files)" ) + parser.add_argument("--log_dir", help="Directory to store log files") + parser.add_argument("--tex_template", help="Specify a custom TeX template file") # All of the following use (action="store_true"). This means that # they are by default False. In contrast to the previous ones that @@ -349,28 +331,16 @@ def _parse_cli(arg_list, input=True): # The following are mutually exclusive and each overrides # FRAME_RATE, PIXEL_HEIGHT, and PIXEL_WIDTH, parser.add_argument( - "-l", - "--low_quality", - action="store_true", - help="Render at low quality", + "-l", "--low_quality", action="store_true", help="Render at low quality" ) parser.add_argument( - "-m", - "--medium_quality", - action="store_true", - help="Render at medium quality", + "-m", "--medium_quality", action="store_true", help="Render at medium quality" ) parser.add_argument( - "-e", - "--high_quality", - action="store_true", - help="Render at high quality", + "-e", "--high_quality", action="store_true", help="Render at high quality" ) parser.add_argument( - "-k", - "--fourk_quality", - action="store_true", - help="Render at 4K quality", + "-k", "--fourk_quality", action="store_true", help="Render at 4K quality" ) # This overrides any of the above @@ -392,10 +362,7 @@ def _parse_cli(arg_list, input=True): ) # Specify the manim.cfg file - parser.add_argument( - "--config_file", - help="Specify the configuration file", - ) + parser.add_argument("--config_file", help="Specify the configuration file") # Specify whether to use the custom folders parser.add_argument( @@ -591,9 +558,7 @@ def _init_cfg_subcmd(subparsers): :class:`argparse.ArgumentParser` The parser that parser anything cfg subcommand related. """ - cfg_related = subparsers.add_parser( - "cfg", - ) + cfg_related = subparsers.add_parser("cfg") cfg_subparsers = cfg_related.add_subparsers(dest="cfg_subcommand") cfg_write_parser = cfg_subparsers.add_parser("write") diff --git a/manim/mobject/changing.py b/manim/mobject/changing.py index 38eae65bab..28b497a43b 100644 --- a/manim/mobject/changing.py +++ b/manim/mobject/changing.py @@ -7,7 +7,7 @@ from ..mobject.types.vectorized_mobject import VGroup from ..utils.rate_functions import smooth from ..utils.space_ops import get_norm -from ..utils.color import BLUE_D, BLUE_B, BLUE_E, GREY_BROWN, WHITE +from ..utils.color import BLUE_D, BLUE_B, BLUE_E, GREY_BROWN, WHITE class AnimatedBoundary(VGroup): diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py index 37a1184715..a5336431a1 100644 --- a/manim/mobject/coordinate_systems.py +++ b/manim/mobject/coordinate_systems.py @@ -87,8 +87,7 @@ def get_axis_label(self, label_tex, axis, edge, direction, buff=MED_SMALL_BUFF): def get_axis_labels(self, x_label_tex="x", y_label_tex="y"): self.axis_labels = VGroup( - self.get_x_axis_label(x_label_tex), - self.get_y_axis_label(y_label_tex), + self.get_x_axis_label(x_label_tex), self.get_y_axis_label(y_label_tex) ) return self.axis_labels @@ -157,9 +156,7 @@ def __init__(self, **kwargs): def create_axis(self, min_val, max_val, axis_config): new_config = merge_dicts_recursively( - self.axis_config, - {"x_min": min_val, "x_max": max_val}, - axis_config, + self.axis_config, {"x_min": min_val, "x_max": max_val}, axis_config ) return NumberLine(**new_config) @@ -236,10 +233,7 @@ def add_3d_pieces(self): def set_axis_shading(self): def make_func(axis): vect = self.light_source - return lambda: ( - axis.get_edge_center(-vect), - axis.get_edge_center(vect), - ) + return lambda: (axis.get_edge_center(-vect), axis.get_edge_center(vect)) for axis in self: for submob in axis.family_members_with_points(): @@ -289,16 +283,9 @@ def init_background_lines(self): self.faded_line_style = style self.background_lines, self.faded_lines = self.get_lines() - self.background_lines.set_style( - **self.background_line_style, - ) - self.faded_lines.set_style( - **self.faded_line_style, - ) - self.add_to_back( - self.faded_lines, - self.background_lines, - ) + self.background_lines.set_style(**self.background_line_style) + self.faded_lines.set_style(**self.faded_line_style) + self.add_to_back(self.faded_lines, self.background_lines) def get_lines(self): """Generate all the lines, faded and not faded. Two sets of lines are generated: one parallel to the X-axis, and parallel to the Y-axis. @@ -314,16 +301,10 @@ def get_lines(self): y_freq = self.y_line_frequency x_lines1, x_lines2 = self.get_lines_parallel_to_axis( - x_axis, - y_axis, - x_freq, - self.faded_line_ratio, + x_axis, y_axis, x_freq, self.faded_line_ratio ) y_lines1, y_lines2 = self.get_lines_parallel_to_axis( - y_axis, - x_axis, - y_freq, - self.faded_line_ratio, + y_axis, x_axis, y_freq, self.faded_line_ratio ) lines1 = VGroup(*x_lines1, *y_lines1) lines2 = VGroup(*x_lines2, *y_lines2) @@ -400,10 +381,7 @@ def prepare_for_nonlinear_transform(self, num_inserted_curves=50): class ComplexPlane(NumberPlane): - CONFIG = { - "color": BLUE, - "line_frequency": 1, - } + CONFIG = {"color": BLUE, "line_frequency": 1} def number_to_point(self, number): number = complex(number) @@ -436,8 +414,7 @@ def get_coordinate_labels(self, *numbers, **kwargs): axis = self.get_y_axis() value = z.imag kwargs = merge_dicts_recursively( - kwargs, - {"number_config": {"unit": "i"}}, + kwargs, {"number_config": {"unit": "i"}} ) else: axis = self.get_x_axis() diff --git a/manim/mobject/frame.py b/manim/mobject/frame.py index 17f4ce22bc..cf4d24760e 100644 --- a/manim/mobject/frame.py +++ b/manim/mobject/frame.py @@ -12,7 +12,7 @@ from ..constants import * from ..mobject.geometry import Rectangle from ..utils.config_ops import digest_config -from ..utils.color import BLACK +from ..utils.color import BLACK class ScreenRectangle(Rectangle): @@ -30,11 +30,7 @@ def __init__(self, **kwargs): class FullScreenFadeRectangle(FullScreenRectangle): - CONFIG = { - "stroke_width": 0, - "fill_color": BLACK, - "fill_opacity": 0.7, - } + CONFIG = {"stroke_width": 0, "fill_color": BLACK, "fill_opacity": 0.7} class PictureInPictureFrame(Rectangle): diff --git a/manim/mobject/functions.py b/manim/mobject/functions.py index 3358405df4..bfb658fd34 100644 --- a/manim/mobject/functions.py +++ b/manim/mobject/functions.py @@ -7,7 +7,7 @@ from ..constants import * from ..mobject.types.vectorized_mobject import VMobject from ..utils.config_ops import digest_config -from ..utils.color import YELLOW +from ..utils.color import YELLOW import math @@ -82,9 +82,7 @@ def generate_points(self): class FunctionGraph(ParametricFunction): - CONFIG = { - "color": YELLOW, - } + CONFIG = {"color": YELLOW} def __init__(self, function, **kwargs): digest_config(self, kwargs) diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index 1f6afee437..c88f87c7b6 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -150,10 +150,7 @@ def reset_endpoints_based_on_tip(self, tip, at_start): if at_start: self.put_start_and_end_on(tip.base, self.get_end()) else: - self.put_start_and_end_on( - self.get_start(), - tip.base, - ) + self.put_start_and_end_on(self.get_start(), tip.base) return self def asign_tip_attr(self, tip, at_start): @@ -258,9 +255,7 @@ def set_pre_positioned_points(self): [ np.cos(a) * RIGHT + np.sin(a) * UP for a in np.linspace( - self.start_angle, - self.start_angle + self.angle, - self.num_components, + self.start_angle, self.start_angle + self.angle, self.num_components ) ] ) @@ -274,12 +269,7 @@ def set_pre_positioned_points(self): # Use tangent vectors to deduce anchors handles1 = anchors[:-1] + (d_theta / 3) * tangent_vectors[:-1] handles2 = anchors[1:] - (d_theta / 3) * tangent_vectors[1:] - self.set_anchors_and_handles( - anchors[:-1], - handles1, - handles2, - anchors[1:], - ) + self.set_anchors_and_handles(anchors[:-1], handles1, handles2, anchors[1:]) def get_arc_center(self, warning=True): """ @@ -301,10 +291,7 @@ def get_arc_center(self, warning=True): n1 = rotate_vector(t1, TAU / 4) n2 = rotate_vector(t2, TAU / 4) try: - return line_intersection( - line1=(a1, a1 + n1), - line2=(a2, a2 + n2), - ) + return line_intersection(line1=(a1, a1 + n1), line2=(a2, a2 + n2)) except Exception: if warning: warnings.warn("Can't find Arc center, using ORIGIN instead") @@ -341,11 +328,7 @@ def __init__(self, start, end, angle=TAU / 4, radius=None, **kwargs): arc_height = radius - math.sqrt(radius ** 2 - halfdist ** 2) angle = math.acos((radius - arc_height) / radius) * sign - Arc.__init__( - self, - angle=angle, - **kwargs, - ) + Arc.__init__(self, angle=angle, **kwargs) if angle == 0: self.set_points_as_corners([LEFT, RIGHT]) self.put_start_and_end_on(start, end) @@ -410,9 +393,7 @@ def __init__(self, point=ORIGIN, **kwargs): class SmallDot(Dot): - CONFIG = { - "radius": DEFAULT_SMALL_DOT_RADIUS, - } + CONFIG = {"radius": DEFAULT_SMALL_DOT_RADIUS} class Ellipse(Circle): @@ -477,10 +458,7 @@ def generate_points(self): class Line(TipableVMobject): - CONFIG = { - "buff": 0, - "path_arc": None, # angle of arc specified here - } + CONFIG = {"buff": 0, "path_arc": None} # angle of arc specified here def __init__(self, start=LEFT, end=RIGHT, **kwargs): digest_config(self, kwargs) @@ -558,10 +536,7 @@ def get_slope(self): return np.tan(self.get_angle()) def set_angle(self, angle): - self.rotate( - angle - self.get_angle(), - about_point=self.get_start(), - ) + self.rotate(angle - self.get_angle(), about_point=self.get_start()) def set_length(self, length): self.scale(length / self.get_length()) @@ -601,10 +576,7 @@ def calculate_num_dashes(self, positive_space_ratio): return 1 def calculate_positive_space_ratio(self): - return fdiv( - self.dash_length, - self.dash_length + self.dash_spacing, - ) + return fdiv(self.dash_length, self.dash_length + self.dash_spacing) def get_start(self): if len(self.submobjects) > 0: @@ -640,10 +612,7 @@ def __init__(self, vmob, alpha, **kwargs): class Elbow(VMobject): - CONFIG = { - "width": 0.2, - "angle": 0, - } + CONFIG = {"width": 0.2, "angle": 0} def __init__(self, **kwargs): VMobject.__init__(self, **kwargs) @@ -727,27 +696,19 @@ def reset_normal_vector(self): def get_default_tip_length(self): max_ratio = self.max_tip_length_to_length_ratio - return min( - self.tip_length, - max_ratio * self.get_length(), - ) + return min(self.tip_length, max_ratio * self.get_length()) def set_stroke_width_from_length(self): max_ratio = self.max_stroke_width_to_length_ratio self.set_stroke( - width=min( - self.initial_stroke_width, - max_ratio * self.get_length(), - ), + width=min(self.initial_stroke_width, max_ratio * self.get_length()), family=False, ) return self class Vector(Arrow): - CONFIG = { - "buff": 0, - } + CONFIG = {"buff": 0} def __init__(self, direction=RIGHT, **kwargs): if len(direction) == 2: @@ -773,9 +734,7 @@ def __init__(self, points, **kwargs): class Polygon(VMobject): - CONFIG = { - "color": BLUE, - } + CONFIG = {"color": BLUE} def __init__(self, *vertices, **kwargs): VMobject.__init__(self, **kwargs) @@ -820,9 +779,7 @@ def round_corners(self, radius=0.5): class RegularPolygon(Polygon): - CONFIG = { - "start_angle": None, - } + CONFIG = {"start_angle": None} def __init__(self, n=6, **kwargs): digest_config(self, kwargs, locals()) @@ -857,9 +814,7 @@ def __init__(self, **kwargs): class Square(Rectangle): - CONFIG = { - "side_length": 2.0, - } + CONFIG = {"side_length": 2.0} def __init__(self, **kwargs): digest_config(self, kwargs) @@ -869,9 +824,7 @@ def __init__(self, **kwargs): class RoundedRectangle(Rectangle): - CONFIG = { - "corner_radius": 0.5, - } + CONFIG = {"corner_radius": 0.5} def __init__(self, **kwargs): Rectangle.__init__(self, **kwargs) diff --git a/manim/mobject/matrix.py b/manim/mobject/matrix.py index d6e4a7ed1a..8354e45cc0 100644 --- a/manim/mobject/matrix.py +++ b/manim/mobject/matrix.py @@ -188,15 +188,11 @@ class DecimalMatrix(Matrix): class IntegerMatrix(Matrix): - CONFIG = { - "element_to_mobject": Integer, - } + CONFIG = {"element_to_mobject": Integer} class MobjectMatrix(Matrix): - CONFIG = { - "element_to_mobject": lambda m: m, - } + CONFIG = {"element_to_mobject": lambda m: m} def get_det_text( diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 3b6f6e6e50..575d106dfa 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -42,13 +42,7 @@ class Mobject(Container): """ - CONFIG = { - "color": WHITE, - "name": None, - "dim": 3, - "target": None, - "z_index": 0, - } + CONFIG = {"color": WHITE, "name": None, "dim": 3, "target": None, "z_index": 0} def __init__(self, **kwargs): Container.__init__(self, **kwargs) @@ -607,10 +601,7 @@ def put_start_and_end_on(self, start, end): if np.all(curr_vect == 0): raise Exception("Cannot position endpoints of closed loop") target_vect = np.array(end) - np.array(start) - self.scale( - get_norm(target_vect) / get_norm(curr_vect), - about_point=curr_start, - ) + self.scale(get_norm(target_vect) / get_norm(curr_vect), about_point=curr_start) self.rotate( angle_of_vector(target_vect) - angle_of_vector(curr_vect), about_point=curr_start, @@ -916,9 +907,7 @@ def match_depth(self, mobject, **kwargs): def match_coord(self, mobject, dim, direction=ORIGIN): return self.set_coord( - mobject.get_coord(dim, direction), - dim=dim, - direction=direction, + mobject.get_coord(dim, direction), dim=dim, direction=direction ) def match_x(self, mobject, direction=ORIGIN): diff --git a/manim/mobject/number_line.py b/manim/mobject/number_line.py index 3d5935bec5..0119b5efa5 100644 --- a/manim/mobject/number_line.py +++ b/manim/mobject/number_line.py @@ -16,7 +16,7 @@ from ..utils.config_ops import merge_dicts_recursively from ..utils.simple_functions import fdiv from ..utils.space_ops import normalize -from ..utils.color import LIGHT_GREY +from ..utils.color import LIGHT_GREY class NumberLine(Line): @@ -43,9 +43,7 @@ class NumberLine(Line): "tip_height": 0.25, "add_start": 0, # extend number line by this amount at its starting point "add_end": 0, # extend number line by this amount at its end point - "decimal_number_config": { - "num_decimal_places": 0, - }, + "decimal_number_config": {"num_decimal_places": 0}, "exclude_zero_from_default_numbers": False, } @@ -86,10 +84,7 @@ def add_tick_marks(self): for x in self.numbers_with_elongated_ticks ] ) - self.add( - self.tick_marks, - self.big_tick_marks, - ) + self.add(self.tick_marks, self.big_tick_marks) def get_tick(self, x, size=None): if size is None: @@ -101,10 +96,7 @@ def get_tick(self, x, size=None): return result def get_tick_marks(self): - return VGroup( - *self.tick_marks, - *self.big_tick_marks, - ) + return VGroup(*self.tick_marks, *self.big_tick_marks) def get_tick_numbers(self): u = -1 if self.include_tip and self.add_end == 0 else 1 @@ -147,10 +139,7 @@ def get_unit_size(self): def default_numbers_to_display(self): if self.numbers_to_show is not None: return self.numbers_to_show - numbers = np.arange( - np.floor(self.leftmost_tick), - np.ceil(self.x_max), - ) + numbers = np.arange(np.floor(self.leftmost_tick), np.ceil(self.x_max)) if self.exclude_zero_from_default_numbers: numbers = numbers[numbers != 0] return numbers @@ -159,8 +148,7 @@ def get_number_mobject( self, number, number_config=None, scale_val=None, direction=None, buff=None ): number_config = merge_dicts_recursively( - self.decimal_number_config, - number_config or {}, + self.decimal_number_config, number_config or {} ) if scale_val is None: scale_val = self.number_scale_val @@ -195,9 +183,7 @@ class UnitInterval(NumberLine): "tick_frequency": 0.1, "numbers_with_elongated_ticks": [0, 1], "number_at_center": 0.5, - "decimal_number_config": { - "num_decimal_places": 1, - }, + "decimal_number_config": {"num_decimal_places": 1}, } def __init__(self, **kwargs): diff --git a/manim/mobject/numbers.py b/manim/mobject/numbers.py index f4f4a308c1..4ef8866c86 100644 --- a/manim/mobject/numbers.py +++ b/manim/mobject/numbers.py @@ -83,11 +83,7 @@ def get_formatter(self, **kwargs): config = dict( [ (attr, getattr(self, attr)) - for attr in [ - "include_sign", - "group_with_commas", - "num_decimal_places", - ] + for attr in ["include_sign", "group_with_commas", "num_decimal_places"] ] ) config.update(kwargs) @@ -141,9 +137,7 @@ def increment_value(self, delta_t=1): class Integer(DecimalNumber): - CONFIG = { - "num_decimal_places": 0, - } + CONFIG = {"num_decimal_places": 0} def get_value(self): return int(np.round(super().get_value())) diff --git a/manim/mobject/probability.py b/manim/mobject/probability.py index 02643aa5ab..f8ab706d7f 100644 --- a/manim/mobject/probability.py +++ b/manim/mobject/probability.py @@ -11,7 +11,16 @@ from ..mobject.svg.tex_mobject import MathTex from ..mobject.svg.tex_mobject import Tex from ..mobject.types.vectorized_mobject import VGroup -from ..utils.color import color_gradient, DARK_GREY, LIGHT_GREY, GREEN_E, BLUE_E, MAROON_B, YELLOW, BLUE +from ..utils.color import ( + color_gradient, + DARK_GREY, + LIGHT_GREY, + GREEN_E, + BLUE_E, + MAROON_B, + YELLOW, + BLUE, +) from ..utils.iterables import tuplify EPSILON = 0.0001 diff --git a/manim/mobject/shape_matchers.py b/manim/mobject/shape_matchers.py index a9bf1e0cb8..354376eb36 100644 --- a/manim/mobject/shape_matchers.py +++ b/manim/mobject/shape_matchers.py @@ -13,10 +13,7 @@ class SurroundingRectangle(Rectangle): - CONFIG = { - "color": YELLOW, - "buff": SMALL_BUFF, - } + CONFIG = {"color": YELLOW, "buff": SMALL_BUFF} def __init__(self, mobject, **kwargs): digest_config(self, kwargs) @@ -66,25 +63,18 @@ def get_fill_color(self): class Cross(VGroup): - CONFIG = { - "stroke_color": RED, - "stroke_width": 6, - } + CONFIG = {"stroke_color": RED, "stroke_width": 6} def __init__(self, mobject, **kwargs): VGroup.__init__( - self, - Line(UP + LEFT, DOWN + RIGHT), - Line(UP + RIGHT, DOWN + LEFT), + self, Line(UP + LEFT, DOWN + RIGHT), Line(UP + RIGHT, DOWN + LEFT) ) self.replace(mobject, stretch=True) self.set_stroke(self.stroke_color, self.stroke_width) class Underline(Line): - CONFIG = { - "buff": SMALL_BUFF, - } + CONFIG = {"buff": SMALL_BUFF} def __init__(self, mobject, **kwargs): super().__init__(LEFT, RIGHT, **kwargs) diff --git a/manim/mobject/svg/brace.py b/manim/mobject/svg/brace.py index 379d878a22..e4d2070b73 100644 --- a/manim/mobject/svg/brace.py +++ b/manim/mobject/svg/brace.py @@ -79,10 +79,7 @@ def get_direction(self): class BraceLabel(VMobject): - CONFIG = { - "label_constructor": MathTex, - "label_scale": 1, - } + CONFIG = {"label_constructor": MathTex, "label_scale": 1} def __init__(self, obj, text, brace_direction=DOWN, **kwargs): VMobject.__init__(self, **kwargs) diff --git a/manim/mobject/svg/code_mobject.py b/manim/mobject/svg/code_mobject.py index 86a98e6a2b..980063ef79 100644 --- a/manim/mobject/svg/code_mobject.py +++ b/manim/mobject/svg/code_mobject.py @@ -1,10 +1,6 @@ """Mobject representing highlighted source code listings.""" -__all__ = [ - "Code", - "hilite_me", - "insert_line_numbers_in_html", -] +__all__ = ["Code", "hilite_me", "insert_line_numbers_in_html"] import html import os diff --git a/manim/mobject/svg/drawings.py b/manim/mobject/svg/drawings.py index 2eeaacbbe0..75891d1269 100644 --- a/manim/mobject/svg/drawings.py +++ b/manim/mobject/svg/drawings.py @@ -55,7 +55,19 @@ from ...utils.space_ops import angle_of_vector from ...utils.space_ops import complex_to_R3 from ...utils.space_ops import rotate_vector -from ...utils.color import YELLOW, WHITE, DARK_GREY, MAROON_B, PURPLE, GREEN, BLACK, LIGHT_GREY, GREY, BLUE_B, BLUE_D +from ...utils.color import ( + YELLOW, + WHITE, + DARK_GREY, + MAROON_B, + PURPLE, + GREEN, + BLACK, + LIGHT_GREY, + GREY, + BLUE_B, + BLUE_D, +) class Lightbulb(SVGMobject): @@ -161,10 +173,7 @@ def move_needle_to_velocity(self, velocity): class AoPSLogo(SVGMobject): - CONFIG = { - "file_name": "aops_logo", - "height": 1.5, - } + CONFIG = {"file_name": "aops_logo", "height": 1.5} def __init__(self, **kwargs): SVGMobject.__init__(self, **kwargs) @@ -217,11 +226,7 @@ class Laptop(VGroup): "keyboard_width_to_body_width": 0.9, "keyboard_height_to_body_height": 0.5, "screen_width_to_screen_plate_width": 0.9, - "key_color_kwargs": { - "stroke_width": 0, - "fill_color": BLACK, - "fill_opacity": 1, - }, + "key_color_kwargs": {"stroke_width": 0, "fill_color": BLACK, "fill_opacity": 1}, "fill_opacity": 1, "stroke_width": 0, "body_color": LIGHT_GREY, @@ -248,21 +253,17 @@ def __init__(self, **kwargs): ] ).arrange(DOWN, buff=MED_SMALL_BUFF) keyboard.stretch_to_fit_width( - self.keyboard_width_to_body_width * body.get_width(), + self.keyboard_width_to_body_width * body.get_width() ) keyboard.stretch_to_fit_height( - self.keyboard_height_to_body_height * body.get_height(), + self.keyboard_height_to_body_height * body.get_height() ) keyboard.next_to(body, OUT, buff=0.1 * SMALL_BUFF) keyboard.shift(MED_SMALL_BUFF * UP) body.add(keyboard) screen_plate.stretch(self.screen_thickness / self.body_dimensions[2], dim=2) - screen = Rectangle( - stroke_width=0, - fill_color=BLACK, - fill_opacity=1, - ) + screen = Rectangle(stroke_width=0, fill_color=BLACK, fill_opacity=1) screen.replace(screen_plate, stretch=True) screen.scale_in_place(self.screen_width_to_screen_plate_width) screen.next_to(screen_plate, OUT, buff=0.1 * SMALL_BUFF) @@ -304,9 +305,7 @@ def __init__(self, **kwargs): class VideoIcon(SVGMobject): - CONFIG = { - "file_name": "video_icon", - } + CONFIG = {"file_name": "video_icon"} def __init__(self, **kwargs): SVGMobject.__init__(self, **kwargs) @@ -318,10 +317,7 @@ def __init__(self, **kwargs): class VideoSeries(VGroup): - CONFIG = { - "num_videos": 11, - "gradient_colors": [BLUE_B, BLUE_D], - } + CONFIG = {"num_videos": 11, "gradient_colors": [BLUE_B, BLUE_D]} def __init__(self, **kwargs): digest_config(self, kwargs) @@ -370,11 +366,7 @@ def __init__(self, **kwargs): class ClockPassesTime(Animation): - CONFIG = { - "run_time": 5, - "hours_passed": 12, - "rate_func": linear, - } + CONFIG = {"run_time": 5, "hours_passed": 12, "rate_func": linear} def __init__(self, clock, **kwargs): digest_config(self, kwargs) @@ -501,9 +493,7 @@ class DoubleSpeechBubble(Bubble): class ThoughtBubble(Bubble): - CONFIG = { - "file_name": "Bubbles_thought.svg", - } + CONFIG = {"file_name": "Bubbles_thought.svg"} def __init__(self, **kwargs): Bubble.__init__(self, **kwargs) @@ -591,19 +581,12 @@ def get_rear_light(self): class VectorizedEarth(SVGMobject): - CONFIG = { - "file_name": "earth", - "height": 1.5, - "fill_color": BLACK, - } + CONFIG = {"file_name": "earth", "height": 1.5, "fill_color": BLACK} def __init__(self, **kwargs): SVGMobject.__init__(self, **kwargs) circle = Circle( - stroke_width=3, - stroke_color=GREEN, - fill_opacity=1, - fill_color=BLUE_C, + stroke_width=3, stroke_color=GREEN, fill_opacity=1, fill_color=BLUE_C ) circle.replace(self) self.add_to_back(circle) @@ -615,18 +598,8 @@ class Logo(VMobject): "outer_radius": 2.0, "iris_background_blue": "#74C0E3", "iris_background_brown": "#8C6239", - "blue_spike_colors": [ - "#528EA3", - "#3E6576", - "#224C5B", - BLACK, - ], - "brown_spike_colors": [ - "#754C24", - "#603813", - "#42210b", - BLACK, - ], + "blue_spike_colors": ["#528EA3", "#3E6576", "#224C5B", BLACK], + "brown_spike_colors": ["#754C24", "#603813", "#42210b", BLACK], "n_spike_layers": 4, "n_spikes": 28, "spike_angle": TAU / 28, @@ -657,19 +630,13 @@ def add_iris_back(self): fill_opacity=1, stroke_width=0, ) - self.iris_background = VGroup( - blue_iris_back, - brown_iris_back, - ) + self.iris_background = VGroup(blue_iris_back, brown_iris_back) self.add(self.iris_background) def add_spikes(self): layers = VGroup() radii = np.linspace( - self.outer_radius, - self.pupil_radius, - self.n_spike_layers, - endpoint=False, + self.outer_radius, self.pupil_radius, self.n_spike_layers, endpoint=False ) radii[:2] = radii[1::-1] # Swap first two if self.n_spike_layers > 2: @@ -686,10 +653,7 @@ def add_spikes(self): fill_opacity=1, stroke_width=0, ) - for vertex3 in ( - half_base * LEFT, - ORIGIN, - ) + for vertex3 in (half_base * LEFT, ORIGIN) ] left_half_triangle = right_half_triangle.copy() left_half_triangle.flip(UP, about_point=ORIGIN) @@ -707,14 +671,8 @@ def add_spikes(self): else: half_spikes = [ right_half_triangle.copy(), - left_half_triangle.copy().rotate( - 90 * DEGREES, - about_point=ORIGIN, - ), - right_half_triangle.copy().rotate( - 90 * DEGREES, - about_point=ORIGIN, - ), + left_half_triangle.copy().rotate(90 * DEGREES, about_point=ORIGIN), + right_half_triangle.copy().rotate(90 * DEGREES, about_point=ORIGIN), left_half_triangle.copy(), ] layer = VGroup( @@ -862,12 +820,7 @@ def get_value(self): if value not in self.possible_values: raise Exception("Invalid card value") - face_card_to_value = { - "J": 11, - "Q": 12, - "K": 13, - "A": 14, - } + face_card_to_value = {"J": 11, "Q": 12, "K": 13, "A": 14} try: self.numerical_value = int(value) except: @@ -905,25 +858,9 @@ def get_ace_design(self, symbol): def get_number_design(self, value, symbol): num = int(value) - n_rows = { - 2: 2, - 3: 3, - 4: 2, - 5: 2, - 6: 3, - 7: 3, - 8: 3, - 9: 4, - 10: 4, - }[num] + n_rows = {2: 2, 3: 3, 4: 2, 5: 2, 6: 3, 7: 3, 8: 3, 9: 4, 10: 4}[num] n_cols = 1 if num in [2, 3] else 2 - insertion_indices = { - 5: [0], - 7: [0], - 8: [0, 1], - 9: [1], - 10: [0, 2], - }.get(num, []) + insertion_indices = {5: [0], 7: [0], 8: [0, 1], 9: [1], 10: [0, 2]}.get(num, []) top = self.get_top() + symbol.get_height() * DOWN bottom = self.get_bottom() + symbol.get_height() * UP diff --git a/manim/mobject/svg/tex_mobject.py b/manim/mobject/svg/tex_mobject.py index 9cb359740f..272fe9500d 100644 --- a/manim/mobject/svg/tex_mobject.py +++ b/manim/mobject/svg/tex_mobject.py @@ -145,11 +145,7 @@ def organize_submobjects_left_to_right(self): class MathTex(SingleStringMathTex): - CONFIG = { - "arg_separator": " ", - "substrings_to_isolate": [], - "tex_to_color_map": {}, - } + CONFIG = {"arg_separator": " ", "substrings_to_isolate": [], "tex_to_color_map": {}} def __init__(self, *tex_strings, **kwargs): digest_config(self, kwargs) @@ -254,11 +250,7 @@ def sort_alphabetically(self): class Tex(MathTex): - CONFIG = { - "alignment": "\\centering", - "arg_separator": "", - "type": "text", - } + CONFIG = {"alignment": "\\centering", "arg_separator": "", "type": "text"} class BulletedList(Tex): diff --git a/manim/mobject/svg/text_mobject.py b/manim/mobject/svg/text_mobject.py index 8e69b37f63..048d1af100 100644 --- a/manim/mobject/svg/text_mobject.py +++ b/manim/mobject/svg/text_mobject.py @@ -326,9 +326,7 @@ def text2svg(self): # Following class is just a Little implementation of upcomming feautures. Ignore it for now. class TextWithBackground(Text): - CONFIG = { - "background_color": BLACK, - } + CONFIG = {"background_color": BLACK} def __init__(self, text, **config): Text.__init__(self, text, **config) @@ -425,10 +423,7 @@ class Paragraph(VGroup): """ - CONFIG = { - "line_spacing": -1, - "alignment": None, - } + CONFIG = {"line_spacing": -1, "alignment": None} def __init__(self, *text, **config): VGroup.__init__(self, **config) diff --git a/manim/mobject/three_d_shading_utils.py b/manim/mobject/three_d_shading_utils.py index 25dc41f32e..b7b7f31a74 100644 --- a/manim/mobject/three_d_shading_utils.py +++ b/manim/mobject/three_d_shading_utils.py @@ -7,10 +7,7 @@ def get_3d_vmob_gradient_start_and_end_points(vmob): - return ( - get_3d_vmob_start_corner(vmob), - get_3d_vmob_end_corner(vmob), - ) + return (get_3d_vmob_start_corner(vmob), get_3d_vmob_end_corner(vmob)) def get_3d_vmob_start_corner_index(vmob): @@ -41,8 +38,7 @@ def get_3d_vmob_unit_normal(vmob, point_index): im1 = i - 1 if i > 0 else (n_points - 2) ip1 = i + 1 if i < (n_points - 1) else 1 return get_unit_normal( - vmob.points[ip1] - vmob.points[i], - vmob.points[im1] - vmob.points[i], + vmob.points[ip1] - vmob.points[i], vmob.points[im1] - vmob.points[i] ) diff --git a/manim/mobject/three_d_utils.py b/manim/mobject/three_d_utils.py index ec2ee4d245..39e38f8a0f 100644 --- a/manim/mobject/three_d_utils.py +++ b/manim/mobject/three_d_utils.py @@ -21,10 +21,7 @@ def get_3d_vmob_gradient_start_and_end_points(vmob): - return ( - get_3d_vmob_start_corner(vmob), - get_3d_vmob_end_corner(vmob), - ) + return (get_3d_vmob_start_corner(vmob), get_3d_vmob_end_corner(vmob)) def get_3d_vmob_start_corner_index(vmob): @@ -55,8 +52,7 @@ def get_3d_vmob_unit_normal(vmob, point_index): im3 = i - 3 if i > 2 else (n_points - 4) ip3 = i + 3 if i < (n_points - 3) else 3 unit_normal = get_unit_normal( - vmob.points[ip3] - vmob.points[i], - vmob.points[im3] - vmob.points[i], + vmob.points[ip3] - vmob.points[i], vmob.points[im3] - vmob.points[i] ) if get_norm(unit_normal) == 0: return np.array(UP) diff --git a/manim/mobject/three_dimensions.py b/manim/mobject/three_dimensions.py index 748f737c49..154df1ff43 100644 --- a/manim/mobject/three_dimensions.py +++ b/manim/mobject/three_dimensions.py @@ -8,15 +8,13 @@ from ..mobject.types.vectorized_mobject import VMobject from ..utils.iterables import tuplify from ..utils.space_ops import z_to_vector -from ..utils.color import BLUE_D, BLUE , BLUE_E , LIGHT_GREY +from ..utils.color import BLUE_D, BLUE, BLUE_E, LIGHT_GREY ############## class ThreeDVMobject(VMobject): - CONFIG = { - "shade_in_3d": True, - } + CONFIG = {"shade_in_3d": True} class ParametricSurface(VGroup): @@ -69,13 +67,7 @@ def setup_in_uv_space(self): v1, v2 = v_values[j : j + 2] face = ThreeDVMobject() face.set_points_as_corners( - [ - [u1, v1, 0], - [u2, v1, 0], - [u2, v2, 0], - [u1, v2, 0], - [u1, v1, 0], - ] + [[u1, v1, 0], [u2, v1, 0], [u2, v2, 0], [u1, v2, 0], [u1, v1, 0]] ) faces.add(face) face.u_index = i @@ -132,10 +124,7 @@ class Cube(VGroup): def generate_points(self): for vect in IN, OUT, LEFT, RIGHT, UP, DOWN: - face = Square( - side_length=self.side_length, - shade_in_3d=True, - ) + face = Square(side_length=self.side_length, shade_in_3d=True) face.flip() face.shift(self.side_length * OUT / 2.0) face.apply_matrix(z_to_vector(vect)) diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.py index a4e11136de..6b80030b73 100644 --- a/manim/mobject/types/image_mobject.py +++ b/manim/mobject/types/image_mobject.py @@ -21,10 +21,7 @@ class AbstractImageMobject(Mobject): Automatically filters out black pixels """ - CONFIG = { - "height": 2.0, - "pixel_array_dtype": "uint8", - } + CONFIG = {"height": 2.0, "pixel_array_dtype": "uint8"} def get_pixel_array(self): raise Exception("Not implemented") @@ -35,13 +32,7 @@ def set_color(self): def reset_points(self): # Corresponding corners of image are fixed to these 3 points - self.points = np.array( - [ - UP + LEFT, - UP + RIGHT, - DOWN + LEFT, - ] - ) + self.points = np.array([UP + LEFT, UP + RIGHT, DOWN + LEFT]) self.center() h, w = self.get_pixel_array().shape[:2] self.stretch_to_fit_height(self.height) @@ -49,10 +40,7 @@ def reset_points(self): class ImageMobject(AbstractImageMobject): - CONFIG = { - "invert": False, - "image_mode": "RGBA", - } + CONFIG = {"invert": False, "image_mode": "RGBA"} def __init__(self, filename_or_array, **kwargs): digest_config(self, kwargs) diff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.py index 6c5be357cb..b47c7cdacb 100644 --- a/manim/mobject/types/point_cloud_mobject.py +++ b/manim/mobject/types/point_cloud_mobject.py @@ -15,9 +15,7 @@ class PMobject(Mobject): - CONFIG = { - "stroke_width": DEFAULT_STROKE_WIDTH, - } + CONFIG = {"stroke_width": DEFAULT_STROKE_WIDTH} def reset_points(self): self.rgbas = np.zeros((0, 4)) @@ -162,11 +160,7 @@ def get_point_mobject(self, center=None): def interpolate_color(self, mobject1, mobject2, alpha): self.rgbas = interpolate(mobject1.rgbas, mobject2.rgbas, alpha) self.set_stroke_width( - interpolate( - mobject1.get_stroke_width(), - mobject2.get_stroke_width(), - alpha, - ) + interpolate(mobject1.get_stroke_width(), mobject2.get_stroke_width(), alpha) ) return self @@ -180,9 +174,7 @@ def pointwise_become_partial(self, mobject, a, b): # TODO, Make the two implementations bellow non-redundant class Mobject1D(PMobject): - CONFIG = { - "density": DEFAULT_POINT_DENSITY_1D, - } + CONFIG = {"density": DEFAULT_POINT_DENSITY_1D} def __init__(self, **kwargs): digest_config(self, kwargs) @@ -201,9 +193,7 @@ def add_line(self, start, end, color=None): class Mobject2D(PMobject): - CONFIG = { - "density": DEFAULT_POINT_DENSITY_2D, - } + CONFIG = {"density": DEFAULT_POINT_DENSITY_2D} def __init__(self, **kwargs): digest_config(self, kwargs) @@ -242,9 +232,7 @@ def generate_points(self): class Point(PMobject): - CONFIG = { - "color": BLACK, - } + CONFIG = {"color": BLACK} def __init__(self, location=ORIGIN, **kwargs): PMobject.__init__(self, **kwargs) diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index cbc63d9c85..13a875aa24 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -79,10 +79,7 @@ def get_group_class(self): # Colors def init_colors(self): - self.set_fill( - color=self.fill_color or self.color, - opacity=self.fill_opacity, - ) + self.set_fill(color=self.fill_color or self.color, opacity=self.fill_opacity) self.set_stroke( color=self.stroke_color or self.color, width=self.stroke_width, @@ -93,10 +90,7 @@ def init_colors(self): width=self.background_stroke_width, opacity=self.background_stroke_opacity, ) - self.set_sheen( - factor=self.sheen_factor, - direction=self.sheen_direction, - ) + self.set_sheen(factor=self.sheen_factor, direction=self.sheen_direction) return self def generate_rgbas_array(self, color, opacity): @@ -203,9 +197,7 @@ def set_style( ) if sheen_factor: self.set_sheen( - factor=sheen_factor, - direction=sheen_direction, - family=family, + factor=sheen_factor, direction=sheen_direction, family=family ) if background_image_file: self.color_using_background_image(background_image_file) @@ -254,17 +246,10 @@ def set_opacity(self, opacity, family=True): def fade(self, darkness=0.5, family=True): factor = 1.0 - darkness - self.set_fill( - opacity=factor * self.get_fill_opacity(), - family=False, - ) - self.set_stroke( - opacity=factor * self.get_stroke_opacity(), - family=False, - ) + self.set_fill(opacity=factor * self.get_fill_opacity(), family=False) + self.set_stroke(opacity=factor * self.get_stroke_opacity(), family=False) self.set_background_stroke( - opacity=factor * self.get_stroke_opacity(background=True), - family=False, + opacity=factor * self.get_stroke_opacity(background=True), family=False ) super().fade(darkness, family) return self @@ -680,14 +665,7 @@ def get_anchors(self): if self.points.shape[0] == 1: return self.points return np.array( - list( - it.chain( - *zip( - self.get_start_anchors(), - self.get_end_anchors(), - ) - ) - ) + list(it.chain(*zip(self.get_start_anchors(), self.get_end_anchors()))) ) def get_points_defining_boundary(self): diff --git a/manim/mobject/vector_field.py b/manim/mobject/vector_field.py index 7ac3e439dd..b1a1a0446e 100644 --- a/manim/mobject/vector_field.py +++ b/manim/mobject/vector_field.py @@ -42,10 +42,7 @@ DEFAULT_SCALAR_FIELD_COLORS = [BLUE_E, GREEN, YELLOW, RED] -def get_colored_background_image( - scalar_field_func, - number_to_rgb_func, -): +def get_colored_background_image(scalar_field_func, number_to_rgb_func): ph = config["pixel_height"] pw = config["pixel_width"] fw = config["frame_width"] @@ -66,10 +63,7 @@ def get_colored_background_image( def get_rgb_gradient_function( - min_value=0, - max_value=1, - colors=[BLUE, RED], - flip_alphas=True, # Why? + min_value=0, max_value=1, colors=[BLUE, RED], flip_alphas=True # Why? ): rgbs = np.array(list(map(color_to_rgb, colors))) @@ -240,9 +234,7 @@ def __init__(self, func, **kwargs): if self.color_by_arc_length: len_to_rgb = get_rgb_gradient_function( - self.min_arc_length, - self.max_arc_length, - colors=self.colors, + self.min_arc_length, self.max_arc_length, colors=self.colors ) for line in self: arc_length = line.get_arc_length() @@ -312,11 +304,7 @@ class AnimatedStreamLines(VGroup): CONFIG = { "lag_range": 4, "line_anim_class": ShowPassingFlash, - "line_anim_config": { - "run_time": 4, - "rate_func": linear, - "time_width": 0.3, - }, + "line_anim_config": {"run_time": 4, "rate_func": linear, "time_width": 0.3}, } def __init__(self, stream_lines, **kwargs): diff --git a/manim/scene/reconfigurable_scene.py b/manim/scene/reconfigurable_scene.py index 7f5d3c21d9..6d322e48ad 100644 --- a/manim/scene/reconfigurable_scene.py +++ b/manim/scene/reconfigurable_scene.py @@ -11,9 +11,7 @@ class ReconfigurableScene(Scene): Note, this seems to no longer work as intented. """ - CONFIG = { - "allow_recursion": True, - } + CONFIG = {"allow_recursion": True} def setup(self): self.states = [] diff --git a/manim/scene/scene.py b/manim/scene/scene.py index e3f9925519..5babbbeece 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -65,10 +65,7 @@ def construct(self): def __init__(self, **kwargs): Container.__init__(self, **kwargs) self.camera = self.camera_class(**camera_config) - self.file_writer = SceneFileWriter( - self, - **file_writer_config, - ) + self.file_writer = SceneFileWriter(self, **file_writer_config) self.play_hashes_list = [] self.mobjects = [] self.original_skipping_status = file_writer_config["skip_animations"] @@ -199,10 +196,7 @@ def update_frame( # TODO Description in Docstring if file_writer_config["skip_animations"] and not ignore_skipping: return if mobjects is None: - mobjects = list_update( - self.mobjects, - self.foreground_mobjects, - ) + mobjects = list_update(self.mobjects, self.foreground_mobjects) if background is not None: self.camera.set_pixel_array(background) else: @@ -719,11 +713,7 @@ def compile_play_args_to_animation_list(self, *args, **kwargs): list : list of animations with the parameters applied to them. """ animations = [] - state = { - "curr_method": None, - "last_method": None, - "method_args": [], - } + state = {"curr_method": None, "last_method": None, "method_args": []} def compile_method(state): if state["curr_method"] is None: diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py index e510c351da..d20d81af9a 100644 --- a/manim/scene/scene_file_writer.py +++ b/manim/scene/scene_file_writer.py @@ -61,10 +61,7 @@ def init_output_directories(self): if file_writer_config["media_dir"] != "": if not file_writer_config["custom_folders"]: image_dir = guarantee_existence( - os.path.join( - file_writer_config["images_dir"], - module_directory, - ) + os.path.join(file_writer_config["images_dir"], module_directory) ) else: image_dir = guarantee_existence(file_writer_config["images_dir"]) @@ -97,11 +94,7 @@ def init_output_directories(self): ) if not file_writer_config["custom_folders"]: self.partial_movie_directory = guarantee_existence( - os.path.join( - movie_dir, - "partial_movie_files", - scene_name, - ) + os.path.join(movie_dir, "partial_movie_files", scene_name) ) else: self.partial_movie_directory = guarantee_existence( @@ -264,8 +257,7 @@ def add_audio_segment(self, new_segment, time=None, gain_to_background=None): diff = new_end - curr_end if diff > 0: segment = segment.append( - AudioSegment.silent(int(np.ceil(diff * 1000))), - crossfade=0, + AudioSegment.silent(int(np.ceil(diff * 1000))), crossfade=0 ) self.audio_segment = segment.overlay( new_segment, @@ -434,17 +426,9 @@ def open_movie_pipe(self): if file_writer_config["movie_file_extension"] == ".mov": # This is if the background of the exported # video should be transparent. - command += [ - "-vcodec", - "qtrle", - ] + command += ["-vcodec", "qtrle"] else: - command += [ - "-vcodec", - "libx264", - "-pix_fmt", - "yuv420p", - ] + command += ["-vcodec", "libx264", "-pix_fmt", "yuv420p"] command += [temp_file_path] self.writing_process = subprocess.Popen(command, stdin=subprocess.PIPE) @@ -456,10 +440,7 @@ def close_movie_pipe(self): """ self.writing_process.stdin.close() self.writing_process.wait() - shutil.move( - self.temp_partial_movie_file_path, - self.partial_movie_file_path, - ) + shutil.move(self.temp_partial_movie_file_path, self.partial_movie_file_path) logger.info( f"Animation {self.scene.num_plays} : Partial movie file written in %(path)s", {"path": {self.partial_movie_file_path}}, @@ -550,10 +531,7 @@ def combine_movie_files(self): ) # Makes sure sound file length will match video file self.add_audio_segment(AudioSegment.silent(0)) - self.audio_segment.export( - sound_file_path, - bitrate="312k", - ) + self.audio_segment.export(sound_file_path, bitrate="312k") temp_file_path = movie_file_path.replace(".", "_temp.") commands = [ FFMPEG_BIN, diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py index 5d0f187201..8303967821 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -515,16 +515,9 @@ class LinearTransformationScene(VectorScene): "include_foreground_plane": True, "background_plane_kwargs": { "color": GREY, - "axis_config": { - "stroke_color": LIGHT_GREY, - }, - "axis_config": { - "color": GREY, - }, - "background_line_style": { - "stroke_color": GREY, - "stroke_width": 1, - }, + "axis_config": {"stroke_color": LIGHT_GREY}, + "axis_config": {"color": GREY}, + "background_line_style": {"stroke_color": GREY, "stroke_width": 1}, }, "show_coordinates": False, "show_basis_vectors": True, @@ -569,8 +562,7 @@ def setup(self): self.add_transformable_mobject(self.plane) if self.show_basis_vectors: self.basis_vectors = self.get_basis_vectors( - i_hat_color=self.i_hat_color, - j_hat_color=self.j_hat_color, + i_hat_color=self.i_hat_color, j_hat_color=self.j_hat_color ) self.moving_vectors += list(self.basis_vectors) self.i_hat, self.j_hat = self.basis_vectors diff --git a/manim/scene/zoomed_scene.py b/manim/scene/zoomed_scene.py index acbf1997fd..a2583a2e36 100644 --- a/manim/scene/zoomed_scene.py +++ b/manim/scene/zoomed_scene.py @@ -85,10 +85,7 @@ def activate_zooming(self, animate=False): if animate: self.play(self.get_zoom_in_animation()) self.play(self.get_zoomed_display_pop_out_animation()) - self.add_foreground_mobjects( - self.zoomed_camera.frame, - self.zoomed_display, - ) + self.add_foreground_mobjects(self.zoomed_camera.frame, self.zoomed_display) def get_zoom_in_animation(self, run_time=2, **kwargs): """ diff --git a/manim/utils/color.py b/manim/utils/color.py index 04cbe2cbf0..18cb6d1eb5 100644 --- a/manim/utils/color.py +++ b/manim/utils/color.py @@ -186,7 +186,7 @@ class Colors(Enum): BLUE_E = Colors.blue_e.value BLUE_D = Colors.blue_d.value BLUE_C = Colors.blue_c.value -BLUE = Colors.blue.value +BLUE = Colors.blue.value BLUE_B = Colors.blue_b.value BLUE_A = Colors.blue_a.value TEAL_E = Colors.teal_e.value @@ -280,7 +280,7 @@ def hex_to_rgb(hex_code): hex_part = hex_code[1:] if len(hex_part) == 3: "".join([2 * c for c in hex_part]) - return np.array([int(hex_part[i: i + 2], 16) / 255 for i in range(0, 6, 2)]) + return np.array([int(hex_part[i : i + 2], 16) / 255 for i in range(0, 6, 2)]) def invert_color(color): @@ -332,9 +332,11 @@ def random_bright_color(): def random_color(): import time + random.seed(time.time()) return random.choice([c.value for c in list(Colors)]) + def get_shaded_rgb(rgb, point, unit_normal_vect, light_source): to_sun = normalize(light_source - point) factor = 0.5 * np.dot(unit_normal_vect, to_sun) ** 3 @@ -342,4 +344,4 @@ def get_shaded_rgb(rgb, point, unit_normal_vect, light_source): factor *= 0.5 result = rgb + factor clip_in_place(rgb + factor, 0, 1) - return result \ No newline at end of file + return result diff --git a/manim/utils/paths.py b/manim/utils/paths.py index addaa84b96..e655977b6f 100644 --- a/manim/utils/paths.py +++ b/manim/utils/paths.py @@ -1,11 +1,6 @@ """Functions determining transformation paths between sets of points.""" -__all__ = [ - "straight_path", - "path_along_arc", - "clockwise_path", - "counterclockwise_path", -] +__all__ = ["straight_path", "path_along_arc", "clockwise_path", "counterclockwise_path"] import numpy as np diff --git a/manim/utils/rate_functions.py b/manim/utils/rate_functions.py index dfd1a0c4d0..24ce770a18 100644 --- a/manim/utils/rate_functions.py +++ b/manim/utils/rate_functions.py @@ -30,11 +30,7 @@ def linear(t): def smooth(t, inflection=10.0): error = sigmoid(-inflection / 2) - return np.clip( - (sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error), - 0, - 1, - ) + return np.clip((sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error), 0, 1) def rush_into(t, inflection=10.0): diff --git a/manim/utils/sounds.py b/manim/utils/sounds.py index dd46294d99..92ecb8cac7 100644 --- a/manim/utils/sounds.py +++ b/manim/utils/sounds.py @@ -14,13 +14,7 @@ def play_chord(*nums): commands = ( - [ - "play", - "-n", - "-c1", - "--no-show-progress", - "synth", - ] + ["play", "-n", "-c1", "--no-show-progress", "synth"] + ["sin %-" + str(num) for num in nums] + ["fade h 0.5 1 0.5", ">", os.devnull] ) diff --git a/tests/helpers/video_utils.py b/tests/helpers/video_utils.py index 5b7aa2791f..218327789d 100644 --- a/tests/helpers/video_utils.py +++ b/tests/helpers/video_utils.py @@ -9,10 +9,7 @@ def capture(command): proc = subprocess.Popen( - command, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding="utf8", + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8" ) out, err = proc.communicate() return out, err, proc.returncode @@ -50,10 +47,7 @@ def save_control_data_from_video(path_to_video, name): tests_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) path_control_data = os.path.join(tests_directory, "control_data", "videos_data") config_video = get_config_from_video(path_to_video) - data = { - "name": name, - "config": json.loads(config_video)["streams"][0], - } + data = {"name": name, "config": json.loads(config_video)["streams"][0]} path_saved = os.path.join(path_control_data, f"{name}.json") json.dump(data, open(path_saved, "w"), indent=4) logger.info(f"Data for {name} saved in {path_saved}") diff --git a/tests/test_family.py b/tests/test_family.py index 47744cbb43..f9747cf000 100644 --- a/tests/test_family.py +++ b/tests/test_family.py @@ -37,11 +37,7 @@ def test_family(): def test_overlapping_family(): """Check that each member of the family is only gathered once.""" - mob, child1, child2, = ( - Mobject(), - Mobject(), - Mobject(), - ) + mob, child1, child2, = (Mobject(), Mobject(), Mobject()) gchild1, gchild2, gchild_common = Mobject(), Mobject(), Mobject() child1.add(gchild1, gchild_common) child2.add(gchild2, gchild_common) @@ -61,11 +57,7 @@ def test_shift_family(): """ # Note shift() needs the mobject to have a non-empty `points` attribute, so # we cannot use a plain Mobject or VMobject. We use Circle instead. - mob, child1, child2, = ( - Circle(), - Circle(), - Circle(), - ) + mob, child1, child2, = (Circle(), Circle(), Circle()) gchild1, gchild2, gchild_common = Circle(), Circle(), Circle() child1.add(gchild1, gchild_common) diff --git a/tests/test_logging/basic_scenes.py b/tests/test_logging/basic_scenes.py index 3f190f36e8..d1bd250da7 100644 --- a/tests/test_logging/basic_scenes.py +++ b/tests/test_logging/basic_scenes.py @@ -11,9 +11,7 @@ def construct(self): class WriteStuff(Scene): def construct(self): example_text = Tex("This is a some text", tex_to_color_map={"text": YELLOW}) - example_tex = MathTex( - "\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}", - ) + example_tex = MathTex("\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}") group = VGroup(example_text, example_tex) group.arrange(DOWN) group.set_width(config["frame_width"] - 2 * LARGE_BUFF) diff --git a/tests/utils/GraphicalUnitTester.py b/tests/utils/GraphicalUnitTester.py index ef8cb4e373..5dc77e8a55 100644 --- a/tests/utils/GraphicalUnitTester.py +++ b/tests/utils/GraphicalUnitTester.py @@ -32,12 +32,7 @@ class GraphicalUnitTester: The scene tested """ - def __init__( - self, - scene_object, - module_tested, - tmpdir, - ): + def __init__(self, scene_object, module_tested, tmpdir): # Disable the the logs, (--quiet is broken) TODO logging.disable(logging.CRITICAL) tests_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/tests/utils/commands.py b/tests/utils/commands.py index 90c5d3caf1..5414b56ce5 100644 --- a/tests/utils/commands.py +++ b/tests/utils/commands.py @@ -3,10 +3,7 @@ def capture(command): proc = subprocess.Popen( - command, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding="utf8", + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8" ) out, err = proc.communicate() return out, err, proc.returncode From c6f075ce423ac5c00b44e807e8f7f4bef357e888 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 11:59:24 +0200 Subject: [PATCH 06/13] # run black 20.8b1 --- tests/test_family.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_family.py b/tests/test_family.py index f9747cf000..e5a49cb2d3 100644 --- a/tests/test_family.py +++ b/tests/test_family.py @@ -37,7 +37,11 @@ def test_family(): def test_overlapping_family(): """Check that each member of the family is only gathered once.""" - mob, child1, child2, = (Mobject(), Mobject(), Mobject()) + ( + mob, + child1, + child2, + ) = (Mobject(), Mobject(), Mobject()) gchild1, gchild2, gchild_common = Mobject(), Mobject(), Mobject() child1.add(gchild1, gchild_common) child2.add(gchild2, gchild_common) @@ -57,7 +61,11 @@ def test_shift_family(): """ # Note shift() needs the mobject to have a non-empty `points` attribute, so # we cannot use a plain Mobject or VMobject. We use Circle instead. - mob, child1, child2, = (Circle(), Circle(), Circle()) + ( + mob, + child1, + child2, + ) = (Circle(), Circle(), Circle()) gchild1, gchild2, gchild_common = Circle(), Circle(), Circle() child1.add(gchild1, gchild_common) From 0930301cb80ae6a723d15ca9d0196db1b937a199 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 15:52:28 +0200 Subject: [PATCH 07/13] Revert "# run black 20.8b1 This reverts commit c6f075ce --- tests/test_family.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/test_family.py b/tests/test_family.py index e5a49cb2d3..f9747cf000 100644 --- a/tests/test_family.py +++ b/tests/test_family.py @@ -37,11 +37,7 @@ def test_family(): def test_overlapping_family(): """Check that each member of the family is only gathered once.""" - ( - mob, - child1, - child2, - ) = (Mobject(), Mobject(), Mobject()) + mob, child1, child2, = (Mobject(), Mobject(), Mobject()) gchild1, gchild2, gchild_common = Mobject(), Mobject(), Mobject() child1.add(gchild1, gchild_common) child2.add(gchild2, gchild_common) @@ -61,11 +57,7 @@ def test_shift_family(): """ # Note shift() needs the mobject to have a non-empty `points` attribute, so # we cannot use a plain Mobject or VMobject. We use Circle instead. - ( - mob, - child1, - child2, - ) = (Circle(), Circle(), Circle()) + mob, child1, child2, = (Circle(), Circle(), Circle()) gchild1, gchild2, gchild_common = Circle(), Circle(), Circle() child1.add(gchild1, gchild_common) From a4ab254be87b0dae064d8ead4f685d211cb801ec Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 15:52:42 +0200 Subject: [PATCH 08/13] Revert "# run black everywhere" This reverts commit 7dee3ba1 --- logo/logo.py | 16 ++- manim/animation/composition.py | 12 +- manim/animation/creation.py | 13 +- manim/animation/fading.py | 40 +++++-- manim/animation/growing.py | 8 +- manim/animation/indication.py | 51 ++++++-- manim/animation/movement.py | 15 ++- manim/animation/numbers.py | 4 +- manim/animation/rotation.py | 5 +- manim/animation/specialized.py | 18 ++- manim/animation/transform.py | 19 ++- manim/animation/update.py | 9 +- manim/camera/mapping_camera.py | 9 +- manim/camera/moving_camera.py | 7 +- manim/camera/multi_camera.py | 4 +- manim/config/config_utils.py | 61 ++++++++-- manim/mobject/changing.py | 2 +- manim/mobject/coordinate_systems.py | 43 +++++-- manim/mobject/frame.py | 8 +- manim/mobject/functions.py | 6 +- manim/mobject/geometry.py | 81 ++++++++++--- manim/mobject/matrix.py | 8 +- manim/mobject/mobject.py | 17 ++- manim/mobject/number_line.py | 28 +++-- manim/mobject/numbers.py | 10 +- manim/mobject/probability.py | 11 +- manim/mobject/shape_matchers.py | 18 ++- manim/mobject/svg/brace.py | 5 +- manim/mobject/svg/code_mobject.py | 6 +- manim/mobject/svg/drawings.py | 131 +++++++++++++++------ manim/mobject/svg/tex_mobject.py | 12 +- manim/mobject/svg/text_mobject.py | 9 +- manim/mobject/three_d_shading_utils.py | 8 +- manim/mobject/three_d_utils.py | 8 +- manim/mobject/three_dimensions.py | 19 ++- manim/mobject/types/image_mobject.py | 18 ++- manim/mobject/types/point_cloud_mobject.py | 22 +++- manim/mobject/types/vectorized_mobject.py | 36 ++++-- manim/mobject/vector_field.py | 20 +++- manim/scene/reconfigurable_scene.py | 4 +- manim/scene/scene.py | 16 ++- manim/scene/scene_file_writer.py | 36 ++++-- manim/scene/vector_space_scene.py | 16 ++- manim/scene/zoomed_scene.py | 5 +- manim/utils/color.py | 8 +- manim/utils/paths.py | 7 +- manim/utils/rate_functions.py | 6 +- manim/utils/sounds.py | 8 +- tests/helpers/video_utils.py | 10 +- tests/test_family.py | 12 +- tests/test_logging/basic_scenes.py | 4 +- tests/utils/GraphicalUnitTester.py | 7 +- tests/utils/commands.py | 5 +- 53 files changed, 739 insertions(+), 222 deletions(-) diff --git a/logo/logo.py b/logo/logo.py index d9b77f379b..235b6c6081 100644 --- a/logo/logo.py +++ b/logo/logo.py @@ -4,7 +4,10 @@ class Thumbnail(GraphScene): - CONFIG = {"y_max": 8, "y_axis_height": 5} + CONFIG = { + "y_max": 8, + "y_axis_height": 5, + } def construct(self): self.show_function_graph() @@ -95,7 +98,7 @@ def get_h_line(input_tracker): graph_dot_p2.move_to(get_graph_point(input_tracker_p2)) # - self.play(ShowCreation(graph)) + self.play(ShowCreation(graph),) # Animacion del punto a self.add_foreground_mobject(graph_dot_p1) self.add_foreground_mobject(graph_dot_p2) @@ -147,11 +150,16 @@ def get_h_line(input_tracker): ) self.add( - input_triangle_p2, graph_dot_p2, v_line_p2, h_line_p2, output_triangle_p2 + input_triangle_p2, graph_dot_p2, v_line_p2, h_line_p2, output_triangle_p2, ) self.play(FadeIn(grupo_secante)) - kwargs = {"x_min": 4, "x_max": 9, "fill_opacity": 0.75, "stroke_width": 0.25} + kwargs = { + "x_min": 4, + "x_max": 9, + "fill_opacity": 0.75, + "stroke_width": 0.25, + } self.graph = graph iteraciones = 6 diff --git a/manim/animation/composition.py b/manim/animation/composition.py index 30cca2a3ea..21ef0845e0 100644 --- a/manim/animation/composition.py +++ b/manim/animation/composition.py @@ -100,7 +100,9 @@ def interpolate(self, alpha): class Succession(AnimationGroup): - CONFIG = {"lag_ratio": 1} + CONFIG = { + "lag_ratio": 1, + } def begin(self): assert len(self.animations) > 0 @@ -125,11 +127,15 @@ def interpolate(self, alpha): class LaggedStart(AnimationGroup): - CONFIG = {"lag_ratio": DEFAULT_LAGGED_START_LAG_RATIO} + CONFIG = { + "lag_ratio": DEFAULT_LAGGED_START_LAG_RATIO, + } class LaggedStartMap(LaggedStart): - CONFIG = {"run_time": 2} + CONFIG = { + "run_time": 2, + } def __init__(self, AnimationClass, mobject, arg_creator=None, **kwargs): args_list = [] diff --git a/manim/animation/creation.py b/manim/animation/creation.py index 065053f883..ef67b0eb9b 100644 --- a/manim/animation/creation.py +++ b/manim/animation/creation.py @@ -41,7 +41,9 @@ def get_bounds(self, alpha): class ShowCreation(ShowPartial): - CONFIG = {"lag_ratio": 1} + CONFIG = { + "lag_ratio": 1, + } def get_bounds(self, alpha): return (0, alpha) @@ -125,7 +127,10 @@ def set_default_config_from_length(self, mobject): class ShowIncreasingSubsets(Animation): - CONFIG = {"suspend_mobject_updating": False, "int_func": np.floor} + CONFIG = { + "suspend_mobject_updating": False, + "int_func": np.floor, + } def __init__(self, group, **kwargs): self.all_submobs = list(group.submobjects) @@ -162,7 +167,9 @@ def __init__(self, text, **kwargs): class ShowSubmobjectsOneByOne(ShowIncreasingSubsets): - CONFIG = {"int_func": np.ceil} + CONFIG = { + "int_func": np.ceil, + } def __init__(self, group, **kwargs): new_group = Group(*group) diff --git a/manim/animation/fading.py b/manim/animation/fading.py index 85232a4aee..1e485435ce 100644 --- a/manim/animation/fading.py +++ b/manim/animation/fading.py @@ -30,7 +30,10 @@ class FadeOut(Transform): - CONFIG = {"remover": True, "lag_ratio": DEFAULT_FADE_LAG_RATIO} + CONFIG = { + "remover": True, + "lag_ratio": DEFAULT_FADE_LAG_RATIO, + } def create_target(self): return self.mobject.copy().fade(1) @@ -41,7 +44,9 @@ def clean_up_from_scene(self, scene=None): class FadeIn(Transform): - CONFIG = {"lag_ratio": DEFAULT_FADE_LAG_RATIO} + CONFIG = { + "lag_ratio": DEFAULT_FADE_LAG_RATIO, + } def create_target(self): return self.mobject @@ -56,7 +61,10 @@ def create_starting_mobject(self): class FadeInFrom(Transform): - CONFIG = {"direction": DOWN, "lag_ratio": DEFAULT_ANIMATION_LAG_RATIO} + CONFIG = { + "direction": DOWN, + "lag_ratio": DEFAULT_ANIMATION_LAG_RATIO, + } def __init__(self, mobject, direction=None, **kwargs): if direction is not None: @@ -78,7 +86,10 @@ class FadeInFromDown(FadeInFrom): communicates the default """ - CONFIG = {"direction": DOWN, "lag_ratio": DEFAULT_ANIMATION_LAG_RATIO} + CONFIG = { + "direction": DOWN, + "lag_ratio": DEFAULT_ANIMATION_LAG_RATIO, + } def __init__(self, mobject, **kwargs): super().__init__(mobject, direction=DOWN, **kwargs) @@ -88,7 +99,9 @@ def __init__(self, mobject, **kwargs): class FadeOutAndShift(FadeOut): - CONFIG = {"direction": DOWN} + CONFIG = { + "direction": DOWN, + } def __init__(self, mobject, direction=None, **kwargs): if direction is not None: @@ -107,7 +120,9 @@ class FadeOutAndShiftDown(FadeOutAndShift): communicates the default """ - CONFIG = {"direction": DOWN} + CONFIG = { + "direction": DOWN, + } def __init__(self, mobject, **kwargs): super().__init__(mobject, direction=DOWN, **kwargs) @@ -129,7 +144,9 @@ def create_starting_mobject(self): class FadeInFromLarge(FadeIn): - CONFIG = {"scale_factor": 2} + CONFIG = { + "scale_factor": 2, + } def __init__(self, mobject, scale_factor=2, **kwargs): if scale_factor is not None: @@ -147,7 +164,9 @@ class VFadeIn(Animation): VFadeIn and VFadeOut only work for VMobjects, """ - CONFIG = {"suspend_mobject_updating": False} + CONFIG = { + "suspend_mobject_updating": False, + } def interpolate_submobject(self, submob, start, alpha): submob.set_stroke(opacity=interpolate(0, start.get_stroke_opacity(), alpha)) @@ -162,4 +181,7 @@ def interpolate_submobject(self, submob, start, alpha): class VFadeInThenOut(VFadeIn): - CONFIG = {"rate_func": there_and_back, "remover": True} + CONFIG = { + "rate_func": there_and_back, + "remover": True, + } diff --git a/manim/animation/growing.py b/manim/animation/growing.py index 0d2bcf873a..62fbee89e0 100644 --- a/manim/animation/growing.py +++ b/manim/animation/growing.py @@ -14,7 +14,9 @@ class GrowFromPoint(Transform): - CONFIG = {"point_color": None} + CONFIG = { + "point_color": None, + } def __init__(self, mobject, point, **kwargs): self.point = point @@ -51,4 +53,6 @@ def __init__(self, arrow, **kwargs): class SpinInFromNothing(GrowFromCenter): - CONFIG = {"path_arc": PI} + CONFIG = { + "path_arc": PI, + } diff --git a/manim/animation/indication.py b/manim/animation/indication.py index 97fd032218..cb1bcd0e14 100644 --- a/manim/animation/indication.py +++ b/manim/animation/indication.py @@ -44,7 +44,12 @@ class FocusOn(Transform): - CONFIG = {"opacity": 0.2, "color": GREY, "run_time": 2, "remover": True} + CONFIG = { + "opacity": 0.2, + "color": GREY, + "run_time": 2, + "remover": True, + } def __init__(self, focus_point, **kwargs): self.focus_point = focus_point @@ -68,7 +73,11 @@ def create_starting_mobject(self): class Indicate(Transform): - CONFIG = {"rate_func": there_and_back, "scale_factor": 1.2, "color": YELLOW} + CONFIG = { + "rate_func": there_and_back, + "scale_factor": 1.2, + "color": YELLOW, + } def create_target(self): target = self.mobject.copy() @@ -92,7 +101,11 @@ def __init__(self, point, color=YELLOW, **kwargs): digest_config(self, kwargs) self.lines = self.create_lines() animations = self.create_line_anims() - super().__init__(*animations, group=self.lines, **kwargs) + super().__init__( + *animations, + group=self.lines, + **kwargs, + ) def create_lines(self): lines = VGroup() @@ -114,7 +127,9 @@ class CircleIndicate(Indicate): CONFIG = { "rate_func": there_and_back, "remover": True, - "circle_config": {"color": YELLOW}, + "circle_config": { + "color": YELLOW, + }, } def __init__(self, mobject, **kwargs): @@ -133,7 +148,10 @@ def interpolate_mobject(self, alpha): class ShowPassingFlash(ShowPartial): - CONFIG = {"time_width": 0.1, "remover": True} + CONFIG = { + "time_width": 0.1, + "remover": True, + } def get_bounds(self, alpha): tw = self.time_width @@ -150,11 +168,16 @@ def finish(self): class ShowCreationThenDestruction(ShowPassingFlash): - CONFIG = {"time_width": 2.0, "run_time": 1} + CONFIG = { + "time_width": 2.0, + "run_time": 1, + } class ShowCreationThenFadeOut(Succession): - CONFIG = {"remover": True} + CONFIG = { + "remover": True, + } def __init__(self, mobject, **kwargs): super().__init__(ShowCreation(mobject), FadeOut(mobject), **kwargs) @@ -178,7 +201,9 @@ def __init__(self, mobject, **kwargs): rect = self.get_rect() rect.add_updater(lambda r: r.move_to(mobject)) - super().__init__(self.rect_animation(rect, **kwargs)) + super().__init__( + self.rect_animation(rect, **kwargs), + ) def get_rect(self): return SurroundingRectangle( @@ -199,7 +224,11 @@ class ShowCreationThenFadeAround(AnimationOnSurroundingRectangle): class ApplyWave(Homotopy): - CONFIG = {"direction": UP, "amplitude": 0.2, "run_time": 1} + CONFIG = { + "direction": UP, + "amplitude": 0.2, + "run_time": 1, + } def __init__(self, mobject, **kwargs): digest_config(self, kwargs, locals()) @@ -247,7 +276,9 @@ def interpolate_submobject(self, submobject, starting_sumobject, alpha): class TurnInsideOut(Transform): - CONFIG = {"path_arc": TAU / 4} + CONFIG = { + "path_arc": TAU / 4, + } def create_target(self): return self.mobject.copy().reverse_points() diff --git a/manim/animation/movement.py b/manim/animation/movement.py index 5fec3192d1..34268237cd 100644 --- a/manim/animation/movement.py +++ b/manim/animation/movement.py @@ -14,7 +14,10 @@ class Homotopy(Animation): - CONFIG = {"run_time": 3, "apply_function_kwargs": {}} + CONFIG = { + "run_time": 3, + "apply_function_kwargs": {}, + } def __init__(self, homotopy, mobject, **kwargs): """ @@ -54,7 +57,11 @@ def homotopy(x, y, z, t): class PhaseFlow(Animation): - CONFIG = {"virtual_time": 1, "rate_func": linear, "suspend_mobject_updating": False} + CONFIG = { + "virtual_time": 1, + "rate_func": linear, + "suspend_mobject_updating": False, + } def __init__(self, function, mobject, **kwargs): self.function = function @@ -68,7 +75,9 @@ def interpolate_mobject(self, alpha): class MoveAlongPath(Animation): - CONFIG = {"suspend_mobject_updating": False} + CONFIG = { + "suspend_mobject_updating": False, + } def __init__(self, mobject, path, **kwargs): self.path = path diff --git a/manim/animation/numbers.py b/manim/animation/numbers.py index e55c50a614..1af261eb1e 100644 --- a/manim/animation/numbers.py +++ b/manim/animation/numbers.py @@ -11,7 +11,9 @@ class ChangingDecimal(Animation): - CONFIG = {"suspend_mobject_updating": False} + CONFIG = { + "suspend_mobject_updating": False, + } def __init__(self, decimal_mob, number_update_func, **kwargs): self.check_validity_of_input(decimal_mob) diff --git a/manim/animation/rotation.py b/manim/animation/rotation.py index 69cdb61c8d..38704f903a 100644 --- a/manim/animation/rotation.py +++ b/manim/animation/rotation.py @@ -32,7 +32,10 @@ def interpolate_mobject(self, alpha): class Rotate(Transform): - CONFIG = {"about_point": None, "about_edge": None} + CONFIG = { + "about_point": None, + "about_edge": None, + } def __init__(self, mobject, angle=PI, axis=OUT, **kwargs): if "path_arc" not in kwargs: diff --git a/manim/animation/specialized.py b/manim/animation/specialized.py index 478c9a43ba..975b60ddcd 100644 --- a/manim/animation/specialized.py +++ b/manim/animation/specialized.py @@ -13,11 +13,14 @@ from ..mobject.types.vectorized_mobject import VGroup from ..utils.config_ops import digest_config from ..utils.space_ops import get_norm -from ..utils.color import BLACK, WHITE +from ..utils.color import BLACK, WHITE class MoveCar(ApplyMethod): - CONFIG = {"moving_forward": True, "run_time": 5} + CONFIG = { + "moving_forward": True, + "run_time": 5, + } def __init__(self, car, target_point, **kwargs): self.check_if_input_is_car(car) @@ -32,7 +35,10 @@ def begin(self): super().begin() car = self.mobject distance = get_norm( - op.sub(self.target_mobject.get_right(), self.starting_mobject.get_right()) + op.sub( + self.target_mobject.get_right(), + self.starting_mobject.get_right(), + ) ) if not self.moving_forward: distance *= -1 @@ -65,7 +71,11 @@ def __init__(self, focal_point, **kwargs): digest_config(self, kwargs) circles = VGroup() for x in range(self.n_circles): - circle = Circle(radius=self.big_radius, stroke_color=BLACK, stroke_width=0) + circle = Circle( + radius=self.big_radius, + stroke_color=BLACK, + stroke_width=0, + ) circle.add_updater(lambda c: c.move_to(focal_point)) circle.save_state() circle.set_width(self.small_radius * 2) diff --git a/manim/animation/transform.py b/manim/animation/transform.py index dc5a560e64..43cd7ac9f5 100644 --- a/manim/animation/transform.py +++ b/manim/animation/transform.py @@ -59,7 +59,10 @@ def init_path_func(self): elif self.path_arc == 0: self.path_func = straight_path else: - self.path_func = path_along_arc(self.path_arc, self.path_arc_axis) + self.path_func = path_along_arc( + self.path_arc, + self.path_arc_axis, + ) def begin(self): # Use a copy of target_mobject for the align_data @@ -108,7 +111,11 @@ def get_all_families_zipped(self): return zip( *[ mob.family_members_with_points() - for mob in [self.mobject, self.starting_mobject, self.target_copy] + for mob in [ + self.mobject, + self.starting_mobject, + self.target_copy, + ] ] ) @@ -118,7 +125,9 @@ def interpolate_submobject(self, submob, start, target_copy, alpha): class ReplacementTransform(Transform): - CONFIG = {"replace_mobject_with_target_in_scene": True} + CONFIG = { + "replace_mobject_with_target_in_scene": True, + } class TransformFromCopy(Transform): @@ -277,7 +286,9 @@ def init_path_func(self): class CyclicReplace(Transform): - CONFIG = {"path_arc": 90 * DEGREES} + CONFIG = { + "path_arc": 90 * DEGREES, + } def __init__(self, *mobjects, **kwargs): self.group = Group(*mobjects) diff --git a/manim/animation/update.py b/manim/animation/update.py index 479e0a7fb6..11934a6dbb 100644 --- a/manim/animation/update.py +++ b/manim/animation/update.py @@ -15,7 +15,9 @@ class UpdateFromFunc(Animation): on another simultaneously animated mobject """ - CONFIG = {"suspend_mobject_updating": False} + CONFIG = { + "suspend_mobject_updating": False, + } def __init__(self, mobject, update_function, **kwargs): self.update_function = update_function @@ -33,7 +35,10 @@ def interpolate_mobject(self, alpha): class MaintainPositionRelativeTo(Animation): def __init__(self, mobject, tracked_mobject, **kwargs): self.tracked_mobject = tracked_mobject - self.diff = op.sub(mobject.get_center(), tracked_mobject.get_center()) + self.diff = op.sub( + mobject.get_center(), + tracked_mobject.get_center(), + ) super().__init__(mobject, **kwargs) def interpolate_mobject(self, alpha): diff --git a/manim/camera/mapping_camera.py b/manim/camera/mapping_camera.py index 2611d70f88..124ed8b741 100644 --- a/manim/camera/mapping_camera.py +++ b/manim/camera/mapping_camera.py @@ -43,7 +43,10 @@ def capture_mobjects(self, mobjects, **kwargs): ): mobject.insert_n_curves(self.min_num_curves) Camera.capture_mobjects( - self, mobject_copies, include_submobjects=False, excluded_mobjects=None + self, + mobject_copies, + include_submobjects=False, + excluded_mobjects=None, ) @@ -124,5 +127,7 @@ def __init__(self, left_camera, right_camera, **kwargs): camera.reset_pixel_shape(camera.pixel_height, half_width) OldMultiCamera.__init__( - self, (left_camera, (0, 0)), (right_camera, (0, half_width)) + self, + (left_camera, (0, 0)), + (right_camera, (0, half_width)), ) diff --git a/manim/camera/moving_camera.py b/manim/camera/moving_camera.py index b5e0d97e54..f5d649f9e6 100644 --- a/manim/camera/moving_camera.py +++ b/manim/camera/moving_camera.py @@ -20,7 +20,9 @@ # TODO, think about how to incorporate perspective class CameraFrame(VGroup): - CONFIG = {"center": ORIGIN} + CONFIG = { + "center": ORIGIN, + } def __init__(self, **kwargs): VGroup.__init__(self, **kwargs) @@ -53,7 +55,8 @@ def __init__(self, frame=None, **kwargs): if frame is None: frame = ScreenRectangle(height=config["frame_height"]) frame.set_stroke( - self.default_frame_stroke_color, self.default_frame_stroke_width + self.default_frame_stroke_color, + self.default_frame_stroke_width, ) self.frame = frame Camera.__init__(self, **kwargs) diff --git a/manim/camera/multi_camera.py b/manim/camera/multi_camera.py index 1e4a640fe3..a503a849a8 100644 --- a/manim/camera/multi_camera.py +++ b/manim/camera/multi_camera.py @@ -10,7 +10,9 @@ class MultiCamera(MovingCamera): """Camera Object that allows for multiple perspectives.""" - CONFIG = {"allow_cameras_to_capture_their_own_display": False} + CONFIG = { + "allow_cameras_to_capture_their_own_display": False, + } def __init__(self, *image_mobjects_from_cameras, **kwargs): """Initalises the MultiCamera diff --git a/manim/config/config_utils.py b/manim/config/config_utils.py index 685485d795..9ec4ca8a68 100644 --- a/manim/config/config_utils.py +++ b/manim/config/config_utils.py @@ -200,7 +200,8 @@ def _parse_cli(arg_list, input=True): if only_manim or not _subcommand_name(ignore=["--help", "-h"]): parser.add_argument( - "file", help="path to file holding the python code for the scene" + "file", + help="path to file holding the python code for the scene", ) parser.add_argument( "scene_names", @@ -236,7 +237,10 @@ def _parse_cli(arg_list, input=True): help="Show the output file in the File Browser", ) parser.add_argument( - "--sound", action="store_const", const=True, help="Play a success/failure sound" + "--sound", + action="store_const", + const=True, + help="Play a success/failure sound", ) parser.add_argument( "--leave_progress_bars", @@ -298,13 +302,27 @@ def _parse_cli(arg_list, input=True): help="Log terminal output to file", ) # The default value of the following is set in manim.cfg - parser.add_argument("-c", "--background_color", help="Specify background color") - parser.add_argument("--background_opacity", help="Specify background opacity") parser.add_argument( - "--media_dir", help="Directory to store media (including video files)" + "-c", + "--background_color", + help="Specify background color", + ) + parser.add_argument( + "--background_opacity", + help="Specify background opacity", + ) + parser.add_argument( + "--media_dir", + help="Directory to store media (including video files)", + ) + parser.add_argument( + "--log_dir", + help="Directory to store log files", + ) + parser.add_argument( + "--tex_template", + help="Specify a custom TeX template file", ) - parser.add_argument("--log_dir", help="Directory to store log files") - parser.add_argument("--tex_template", help="Specify a custom TeX template file") # All of the following use (action="store_true"). This means that # they are by default False. In contrast to the previous ones that @@ -331,16 +349,28 @@ def _parse_cli(arg_list, input=True): # The following are mutually exclusive and each overrides # FRAME_RATE, PIXEL_HEIGHT, and PIXEL_WIDTH, parser.add_argument( - "-l", "--low_quality", action="store_true", help="Render at low quality" + "-l", + "--low_quality", + action="store_true", + help="Render at low quality", ) parser.add_argument( - "-m", "--medium_quality", action="store_true", help="Render at medium quality" + "-m", + "--medium_quality", + action="store_true", + help="Render at medium quality", ) parser.add_argument( - "-e", "--high_quality", action="store_true", help="Render at high quality" + "-e", + "--high_quality", + action="store_true", + help="Render at high quality", ) parser.add_argument( - "-k", "--fourk_quality", action="store_true", help="Render at 4K quality" + "-k", + "--fourk_quality", + action="store_true", + help="Render at 4K quality", ) # This overrides any of the above @@ -362,7 +392,10 @@ def _parse_cli(arg_list, input=True): ) # Specify the manim.cfg file - parser.add_argument("--config_file", help="Specify the configuration file") + parser.add_argument( + "--config_file", + help="Specify the configuration file", + ) # Specify whether to use the custom folders parser.add_argument( @@ -558,7 +591,9 @@ def _init_cfg_subcmd(subparsers): :class:`argparse.ArgumentParser` The parser that parser anything cfg subcommand related. """ - cfg_related = subparsers.add_parser("cfg") + cfg_related = subparsers.add_parser( + "cfg", + ) cfg_subparsers = cfg_related.add_subparsers(dest="cfg_subcommand") cfg_write_parser = cfg_subparsers.add_parser("write") diff --git a/manim/mobject/changing.py b/manim/mobject/changing.py index 28b497a43b..38eae65bab 100644 --- a/manim/mobject/changing.py +++ b/manim/mobject/changing.py @@ -7,7 +7,7 @@ from ..mobject.types.vectorized_mobject import VGroup from ..utils.rate_functions import smooth from ..utils.space_ops import get_norm -from ..utils.color import BLUE_D, BLUE_B, BLUE_E, GREY_BROWN, WHITE +from ..utils.color import BLUE_D, BLUE_B, BLUE_E, GREY_BROWN, WHITE class AnimatedBoundary(VGroup): diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py index a5336431a1..37a1184715 100644 --- a/manim/mobject/coordinate_systems.py +++ b/manim/mobject/coordinate_systems.py @@ -87,7 +87,8 @@ def get_axis_label(self, label_tex, axis, edge, direction, buff=MED_SMALL_BUFF): def get_axis_labels(self, x_label_tex="x", y_label_tex="y"): self.axis_labels = VGroup( - self.get_x_axis_label(x_label_tex), self.get_y_axis_label(y_label_tex) + self.get_x_axis_label(x_label_tex), + self.get_y_axis_label(y_label_tex), ) return self.axis_labels @@ -156,7 +157,9 @@ def __init__(self, **kwargs): def create_axis(self, min_val, max_val, axis_config): new_config = merge_dicts_recursively( - self.axis_config, {"x_min": min_val, "x_max": max_val}, axis_config + self.axis_config, + {"x_min": min_val, "x_max": max_val}, + axis_config, ) return NumberLine(**new_config) @@ -233,7 +236,10 @@ def add_3d_pieces(self): def set_axis_shading(self): def make_func(axis): vect = self.light_source - return lambda: (axis.get_edge_center(-vect), axis.get_edge_center(vect)) + return lambda: ( + axis.get_edge_center(-vect), + axis.get_edge_center(vect), + ) for axis in self: for submob in axis.family_members_with_points(): @@ -283,9 +289,16 @@ def init_background_lines(self): self.faded_line_style = style self.background_lines, self.faded_lines = self.get_lines() - self.background_lines.set_style(**self.background_line_style) - self.faded_lines.set_style(**self.faded_line_style) - self.add_to_back(self.faded_lines, self.background_lines) + self.background_lines.set_style( + **self.background_line_style, + ) + self.faded_lines.set_style( + **self.faded_line_style, + ) + self.add_to_back( + self.faded_lines, + self.background_lines, + ) def get_lines(self): """Generate all the lines, faded and not faded. Two sets of lines are generated: one parallel to the X-axis, and parallel to the Y-axis. @@ -301,10 +314,16 @@ def get_lines(self): y_freq = self.y_line_frequency x_lines1, x_lines2 = self.get_lines_parallel_to_axis( - x_axis, y_axis, x_freq, self.faded_line_ratio + x_axis, + y_axis, + x_freq, + self.faded_line_ratio, ) y_lines1, y_lines2 = self.get_lines_parallel_to_axis( - y_axis, x_axis, y_freq, self.faded_line_ratio + y_axis, + x_axis, + y_freq, + self.faded_line_ratio, ) lines1 = VGroup(*x_lines1, *y_lines1) lines2 = VGroup(*x_lines2, *y_lines2) @@ -381,7 +400,10 @@ def prepare_for_nonlinear_transform(self, num_inserted_curves=50): class ComplexPlane(NumberPlane): - CONFIG = {"color": BLUE, "line_frequency": 1} + CONFIG = { + "color": BLUE, + "line_frequency": 1, + } def number_to_point(self, number): number = complex(number) @@ -414,7 +436,8 @@ def get_coordinate_labels(self, *numbers, **kwargs): axis = self.get_y_axis() value = z.imag kwargs = merge_dicts_recursively( - kwargs, {"number_config": {"unit": "i"}} + kwargs, + {"number_config": {"unit": "i"}}, ) else: axis = self.get_x_axis() diff --git a/manim/mobject/frame.py b/manim/mobject/frame.py index cf4d24760e..17f4ce22bc 100644 --- a/manim/mobject/frame.py +++ b/manim/mobject/frame.py @@ -12,7 +12,7 @@ from ..constants import * from ..mobject.geometry import Rectangle from ..utils.config_ops import digest_config -from ..utils.color import BLACK +from ..utils.color import BLACK class ScreenRectangle(Rectangle): @@ -30,7 +30,11 @@ def __init__(self, **kwargs): class FullScreenFadeRectangle(FullScreenRectangle): - CONFIG = {"stroke_width": 0, "fill_color": BLACK, "fill_opacity": 0.7} + CONFIG = { + "stroke_width": 0, + "fill_color": BLACK, + "fill_opacity": 0.7, + } class PictureInPictureFrame(Rectangle): diff --git a/manim/mobject/functions.py b/manim/mobject/functions.py index bfb658fd34..3358405df4 100644 --- a/manim/mobject/functions.py +++ b/manim/mobject/functions.py @@ -7,7 +7,7 @@ from ..constants import * from ..mobject.types.vectorized_mobject import VMobject from ..utils.config_ops import digest_config -from ..utils.color import YELLOW +from ..utils.color import YELLOW import math @@ -82,7 +82,9 @@ def generate_points(self): class FunctionGraph(ParametricFunction): - CONFIG = {"color": YELLOW} + CONFIG = { + "color": YELLOW, + } def __init__(self, function, **kwargs): digest_config(self, kwargs) diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index c88f87c7b6..1f6afee437 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -150,7 +150,10 @@ def reset_endpoints_based_on_tip(self, tip, at_start): if at_start: self.put_start_and_end_on(tip.base, self.get_end()) else: - self.put_start_and_end_on(self.get_start(), tip.base) + self.put_start_and_end_on( + self.get_start(), + tip.base, + ) return self def asign_tip_attr(self, tip, at_start): @@ -255,7 +258,9 @@ def set_pre_positioned_points(self): [ np.cos(a) * RIGHT + np.sin(a) * UP for a in np.linspace( - self.start_angle, self.start_angle + self.angle, self.num_components + self.start_angle, + self.start_angle + self.angle, + self.num_components, ) ] ) @@ -269,7 +274,12 @@ def set_pre_positioned_points(self): # Use tangent vectors to deduce anchors handles1 = anchors[:-1] + (d_theta / 3) * tangent_vectors[:-1] handles2 = anchors[1:] - (d_theta / 3) * tangent_vectors[1:] - self.set_anchors_and_handles(anchors[:-1], handles1, handles2, anchors[1:]) + self.set_anchors_and_handles( + anchors[:-1], + handles1, + handles2, + anchors[1:], + ) def get_arc_center(self, warning=True): """ @@ -291,7 +301,10 @@ def get_arc_center(self, warning=True): n1 = rotate_vector(t1, TAU / 4) n2 = rotate_vector(t2, TAU / 4) try: - return line_intersection(line1=(a1, a1 + n1), line2=(a2, a2 + n2)) + return line_intersection( + line1=(a1, a1 + n1), + line2=(a2, a2 + n2), + ) except Exception: if warning: warnings.warn("Can't find Arc center, using ORIGIN instead") @@ -328,7 +341,11 @@ def __init__(self, start, end, angle=TAU / 4, radius=None, **kwargs): arc_height = radius - math.sqrt(radius ** 2 - halfdist ** 2) angle = math.acos((radius - arc_height) / radius) * sign - Arc.__init__(self, angle=angle, **kwargs) + Arc.__init__( + self, + angle=angle, + **kwargs, + ) if angle == 0: self.set_points_as_corners([LEFT, RIGHT]) self.put_start_and_end_on(start, end) @@ -393,7 +410,9 @@ def __init__(self, point=ORIGIN, **kwargs): class SmallDot(Dot): - CONFIG = {"radius": DEFAULT_SMALL_DOT_RADIUS} + CONFIG = { + "radius": DEFAULT_SMALL_DOT_RADIUS, + } class Ellipse(Circle): @@ -458,7 +477,10 @@ def generate_points(self): class Line(TipableVMobject): - CONFIG = {"buff": 0, "path_arc": None} # angle of arc specified here + CONFIG = { + "buff": 0, + "path_arc": None, # angle of arc specified here + } def __init__(self, start=LEFT, end=RIGHT, **kwargs): digest_config(self, kwargs) @@ -536,7 +558,10 @@ def get_slope(self): return np.tan(self.get_angle()) def set_angle(self, angle): - self.rotate(angle - self.get_angle(), about_point=self.get_start()) + self.rotate( + angle - self.get_angle(), + about_point=self.get_start(), + ) def set_length(self, length): self.scale(length / self.get_length()) @@ -576,7 +601,10 @@ def calculate_num_dashes(self, positive_space_ratio): return 1 def calculate_positive_space_ratio(self): - return fdiv(self.dash_length, self.dash_length + self.dash_spacing) + return fdiv( + self.dash_length, + self.dash_length + self.dash_spacing, + ) def get_start(self): if len(self.submobjects) > 0: @@ -612,7 +640,10 @@ def __init__(self, vmob, alpha, **kwargs): class Elbow(VMobject): - CONFIG = {"width": 0.2, "angle": 0} + CONFIG = { + "width": 0.2, + "angle": 0, + } def __init__(self, **kwargs): VMobject.__init__(self, **kwargs) @@ -696,19 +727,27 @@ def reset_normal_vector(self): def get_default_tip_length(self): max_ratio = self.max_tip_length_to_length_ratio - return min(self.tip_length, max_ratio * self.get_length()) + return min( + self.tip_length, + max_ratio * self.get_length(), + ) def set_stroke_width_from_length(self): max_ratio = self.max_stroke_width_to_length_ratio self.set_stroke( - width=min(self.initial_stroke_width, max_ratio * self.get_length()), + width=min( + self.initial_stroke_width, + max_ratio * self.get_length(), + ), family=False, ) return self class Vector(Arrow): - CONFIG = {"buff": 0} + CONFIG = { + "buff": 0, + } def __init__(self, direction=RIGHT, **kwargs): if len(direction) == 2: @@ -734,7 +773,9 @@ def __init__(self, points, **kwargs): class Polygon(VMobject): - CONFIG = {"color": BLUE} + CONFIG = { + "color": BLUE, + } def __init__(self, *vertices, **kwargs): VMobject.__init__(self, **kwargs) @@ -779,7 +820,9 @@ def round_corners(self, radius=0.5): class RegularPolygon(Polygon): - CONFIG = {"start_angle": None} + CONFIG = { + "start_angle": None, + } def __init__(self, n=6, **kwargs): digest_config(self, kwargs, locals()) @@ -814,7 +857,9 @@ def __init__(self, **kwargs): class Square(Rectangle): - CONFIG = {"side_length": 2.0} + CONFIG = { + "side_length": 2.0, + } def __init__(self, **kwargs): digest_config(self, kwargs) @@ -824,7 +869,9 @@ def __init__(self, **kwargs): class RoundedRectangle(Rectangle): - CONFIG = {"corner_radius": 0.5} + CONFIG = { + "corner_radius": 0.5, + } def __init__(self, **kwargs): Rectangle.__init__(self, **kwargs) diff --git a/manim/mobject/matrix.py b/manim/mobject/matrix.py index 8354e45cc0..d6e4a7ed1a 100644 --- a/manim/mobject/matrix.py +++ b/manim/mobject/matrix.py @@ -188,11 +188,15 @@ class DecimalMatrix(Matrix): class IntegerMatrix(Matrix): - CONFIG = {"element_to_mobject": Integer} + CONFIG = { + "element_to_mobject": Integer, + } class MobjectMatrix(Matrix): - CONFIG = {"element_to_mobject": lambda m: m} + CONFIG = { + "element_to_mobject": lambda m: m, + } def get_det_text( diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 575d106dfa..3b6f6e6e50 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -42,7 +42,13 @@ class Mobject(Container): """ - CONFIG = {"color": WHITE, "name": None, "dim": 3, "target": None, "z_index": 0} + CONFIG = { + "color": WHITE, + "name": None, + "dim": 3, + "target": None, + "z_index": 0, + } def __init__(self, **kwargs): Container.__init__(self, **kwargs) @@ -601,7 +607,10 @@ def put_start_and_end_on(self, start, end): if np.all(curr_vect == 0): raise Exception("Cannot position endpoints of closed loop") target_vect = np.array(end) - np.array(start) - self.scale(get_norm(target_vect) / get_norm(curr_vect), about_point=curr_start) + self.scale( + get_norm(target_vect) / get_norm(curr_vect), + about_point=curr_start, + ) self.rotate( angle_of_vector(target_vect) - angle_of_vector(curr_vect), about_point=curr_start, @@ -907,7 +916,9 @@ def match_depth(self, mobject, **kwargs): def match_coord(self, mobject, dim, direction=ORIGIN): return self.set_coord( - mobject.get_coord(dim, direction), dim=dim, direction=direction + mobject.get_coord(dim, direction), + dim=dim, + direction=direction, ) def match_x(self, mobject, direction=ORIGIN): diff --git a/manim/mobject/number_line.py b/manim/mobject/number_line.py index 0119b5efa5..3d5935bec5 100644 --- a/manim/mobject/number_line.py +++ b/manim/mobject/number_line.py @@ -16,7 +16,7 @@ from ..utils.config_ops import merge_dicts_recursively from ..utils.simple_functions import fdiv from ..utils.space_ops import normalize -from ..utils.color import LIGHT_GREY +from ..utils.color import LIGHT_GREY class NumberLine(Line): @@ -43,7 +43,9 @@ class NumberLine(Line): "tip_height": 0.25, "add_start": 0, # extend number line by this amount at its starting point "add_end": 0, # extend number line by this amount at its end point - "decimal_number_config": {"num_decimal_places": 0}, + "decimal_number_config": { + "num_decimal_places": 0, + }, "exclude_zero_from_default_numbers": False, } @@ -84,7 +86,10 @@ def add_tick_marks(self): for x in self.numbers_with_elongated_ticks ] ) - self.add(self.tick_marks, self.big_tick_marks) + self.add( + self.tick_marks, + self.big_tick_marks, + ) def get_tick(self, x, size=None): if size is None: @@ -96,7 +101,10 @@ def get_tick(self, x, size=None): return result def get_tick_marks(self): - return VGroup(*self.tick_marks, *self.big_tick_marks) + return VGroup( + *self.tick_marks, + *self.big_tick_marks, + ) def get_tick_numbers(self): u = -1 if self.include_tip and self.add_end == 0 else 1 @@ -139,7 +147,10 @@ def get_unit_size(self): def default_numbers_to_display(self): if self.numbers_to_show is not None: return self.numbers_to_show - numbers = np.arange(np.floor(self.leftmost_tick), np.ceil(self.x_max)) + numbers = np.arange( + np.floor(self.leftmost_tick), + np.ceil(self.x_max), + ) if self.exclude_zero_from_default_numbers: numbers = numbers[numbers != 0] return numbers @@ -148,7 +159,8 @@ def get_number_mobject( self, number, number_config=None, scale_val=None, direction=None, buff=None ): number_config = merge_dicts_recursively( - self.decimal_number_config, number_config or {} + self.decimal_number_config, + number_config or {}, ) if scale_val is None: scale_val = self.number_scale_val @@ -183,7 +195,9 @@ class UnitInterval(NumberLine): "tick_frequency": 0.1, "numbers_with_elongated_ticks": [0, 1], "number_at_center": 0.5, - "decimal_number_config": {"num_decimal_places": 1}, + "decimal_number_config": { + "num_decimal_places": 1, + }, } def __init__(self, **kwargs): diff --git a/manim/mobject/numbers.py b/manim/mobject/numbers.py index 4ef8866c86..f4f4a308c1 100644 --- a/manim/mobject/numbers.py +++ b/manim/mobject/numbers.py @@ -83,7 +83,11 @@ def get_formatter(self, **kwargs): config = dict( [ (attr, getattr(self, attr)) - for attr in ["include_sign", "group_with_commas", "num_decimal_places"] + for attr in [ + "include_sign", + "group_with_commas", + "num_decimal_places", + ] ] ) config.update(kwargs) @@ -137,7 +141,9 @@ def increment_value(self, delta_t=1): class Integer(DecimalNumber): - CONFIG = {"num_decimal_places": 0} + CONFIG = { + "num_decimal_places": 0, + } def get_value(self): return int(np.round(super().get_value())) diff --git a/manim/mobject/probability.py b/manim/mobject/probability.py index f8ab706d7f..02643aa5ab 100644 --- a/manim/mobject/probability.py +++ b/manim/mobject/probability.py @@ -11,16 +11,7 @@ from ..mobject.svg.tex_mobject import MathTex from ..mobject.svg.tex_mobject import Tex from ..mobject.types.vectorized_mobject import VGroup -from ..utils.color import ( - color_gradient, - DARK_GREY, - LIGHT_GREY, - GREEN_E, - BLUE_E, - MAROON_B, - YELLOW, - BLUE, -) +from ..utils.color import color_gradient, DARK_GREY, LIGHT_GREY, GREEN_E, BLUE_E, MAROON_B, YELLOW, BLUE from ..utils.iterables import tuplify EPSILON = 0.0001 diff --git a/manim/mobject/shape_matchers.py b/manim/mobject/shape_matchers.py index 354376eb36..a9bf1e0cb8 100644 --- a/manim/mobject/shape_matchers.py +++ b/manim/mobject/shape_matchers.py @@ -13,7 +13,10 @@ class SurroundingRectangle(Rectangle): - CONFIG = {"color": YELLOW, "buff": SMALL_BUFF} + CONFIG = { + "color": YELLOW, + "buff": SMALL_BUFF, + } def __init__(self, mobject, **kwargs): digest_config(self, kwargs) @@ -63,18 +66,25 @@ def get_fill_color(self): class Cross(VGroup): - CONFIG = {"stroke_color": RED, "stroke_width": 6} + CONFIG = { + "stroke_color": RED, + "stroke_width": 6, + } def __init__(self, mobject, **kwargs): VGroup.__init__( - self, Line(UP + LEFT, DOWN + RIGHT), Line(UP + RIGHT, DOWN + LEFT) + self, + Line(UP + LEFT, DOWN + RIGHT), + Line(UP + RIGHT, DOWN + LEFT), ) self.replace(mobject, stretch=True) self.set_stroke(self.stroke_color, self.stroke_width) class Underline(Line): - CONFIG = {"buff": SMALL_BUFF} + CONFIG = { + "buff": SMALL_BUFF, + } def __init__(self, mobject, **kwargs): super().__init__(LEFT, RIGHT, **kwargs) diff --git a/manim/mobject/svg/brace.py b/manim/mobject/svg/brace.py index e4d2070b73..379d878a22 100644 --- a/manim/mobject/svg/brace.py +++ b/manim/mobject/svg/brace.py @@ -79,7 +79,10 @@ def get_direction(self): class BraceLabel(VMobject): - CONFIG = {"label_constructor": MathTex, "label_scale": 1} + CONFIG = { + "label_constructor": MathTex, + "label_scale": 1, + } def __init__(self, obj, text, brace_direction=DOWN, **kwargs): VMobject.__init__(self, **kwargs) diff --git a/manim/mobject/svg/code_mobject.py b/manim/mobject/svg/code_mobject.py index 980063ef79..86a98e6a2b 100644 --- a/manim/mobject/svg/code_mobject.py +++ b/manim/mobject/svg/code_mobject.py @@ -1,6 +1,10 @@ """Mobject representing highlighted source code listings.""" -__all__ = ["Code", "hilite_me", "insert_line_numbers_in_html"] +__all__ = [ + "Code", + "hilite_me", + "insert_line_numbers_in_html", +] import html import os diff --git a/manim/mobject/svg/drawings.py b/manim/mobject/svg/drawings.py index 75891d1269..2eeaacbbe0 100644 --- a/manim/mobject/svg/drawings.py +++ b/manim/mobject/svg/drawings.py @@ -55,19 +55,7 @@ from ...utils.space_ops import angle_of_vector from ...utils.space_ops import complex_to_R3 from ...utils.space_ops import rotate_vector -from ...utils.color import ( - YELLOW, - WHITE, - DARK_GREY, - MAROON_B, - PURPLE, - GREEN, - BLACK, - LIGHT_GREY, - GREY, - BLUE_B, - BLUE_D, -) +from ...utils.color import YELLOW, WHITE, DARK_GREY, MAROON_B, PURPLE, GREEN, BLACK, LIGHT_GREY, GREY, BLUE_B, BLUE_D class Lightbulb(SVGMobject): @@ -173,7 +161,10 @@ def move_needle_to_velocity(self, velocity): class AoPSLogo(SVGMobject): - CONFIG = {"file_name": "aops_logo", "height": 1.5} + CONFIG = { + "file_name": "aops_logo", + "height": 1.5, + } def __init__(self, **kwargs): SVGMobject.__init__(self, **kwargs) @@ -226,7 +217,11 @@ class Laptop(VGroup): "keyboard_width_to_body_width": 0.9, "keyboard_height_to_body_height": 0.5, "screen_width_to_screen_plate_width": 0.9, - "key_color_kwargs": {"stroke_width": 0, "fill_color": BLACK, "fill_opacity": 1}, + "key_color_kwargs": { + "stroke_width": 0, + "fill_color": BLACK, + "fill_opacity": 1, + }, "fill_opacity": 1, "stroke_width": 0, "body_color": LIGHT_GREY, @@ -253,17 +248,21 @@ def __init__(self, **kwargs): ] ).arrange(DOWN, buff=MED_SMALL_BUFF) keyboard.stretch_to_fit_width( - self.keyboard_width_to_body_width * body.get_width() + self.keyboard_width_to_body_width * body.get_width(), ) keyboard.stretch_to_fit_height( - self.keyboard_height_to_body_height * body.get_height() + self.keyboard_height_to_body_height * body.get_height(), ) keyboard.next_to(body, OUT, buff=0.1 * SMALL_BUFF) keyboard.shift(MED_SMALL_BUFF * UP) body.add(keyboard) screen_plate.stretch(self.screen_thickness / self.body_dimensions[2], dim=2) - screen = Rectangle(stroke_width=0, fill_color=BLACK, fill_opacity=1) + screen = Rectangle( + stroke_width=0, + fill_color=BLACK, + fill_opacity=1, + ) screen.replace(screen_plate, stretch=True) screen.scale_in_place(self.screen_width_to_screen_plate_width) screen.next_to(screen_plate, OUT, buff=0.1 * SMALL_BUFF) @@ -305,7 +304,9 @@ def __init__(self, **kwargs): class VideoIcon(SVGMobject): - CONFIG = {"file_name": "video_icon"} + CONFIG = { + "file_name": "video_icon", + } def __init__(self, **kwargs): SVGMobject.__init__(self, **kwargs) @@ -317,7 +318,10 @@ def __init__(self, **kwargs): class VideoSeries(VGroup): - CONFIG = {"num_videos": 11, "gradient_colors": [BLUE_B, BLUE_D]} + CONFIG = { + "num_videos": 11, + "gradient_colors": [BLUE_B, BLUE_D], + } def __init__(self, **kwargs): digest_config(self, kwargs) @@ -366,7 +370,11 @@ def __init__(self, **kwargs): class ClockPassesTime(Animation): - CONFIG = {"run_time": 5, "hours_passed": 12, "rate_func": linear} + CONFIG = { + "run_time": 5, + "hours_passed": 12, + "rate_func": linear, + } def __init__(self, clock, **kwargs): digest_config(self, kwargs) @@ -493,7 +501,9 @@ class DoubleSpeechBubble(Bubble): class ThoughtBubble(Bubble): - CONFIG = {"file_name": "Bubbles_thought.svg"} + CONFIG = { + "file_name": "Bubbles_thought.svg", + } def __init__(self, **kwargs): Bubble.__init__(self, **kwargs) @@ -581,12 +591,19 @@ def get_rear_light(self): class VectorizedEarth(SVGMobject): - CONFIG = {"file_name": "earth", "height": 1.5, "fill_color": BLACK} + CONFIG = { + "file_name": "earth", + "height": 1.5, + "fill_color": BLACK, + } def __init__(self, **kwargs): SVGMobject.__init__(self, **kwargs) circle = Circle( - stroke_width=3, stroke_color=GREEN, fill_opacity=1, fill_color=BLUE_C + stroke_width=3, + stroke_color=GREEN, + fill_opacity=1, + fill_color=BLUE_C, ) circle.replace(self) self.add_to_back(circle) @@ -598,8 +615,18 @@ class Logo(VMobject): "outer_radius": 2.0, "iris_background_blue": "#74C0E3", "iris_background_brown": "#8C6239", - "blue_spike_colors": ["#528EA3", "#3E6576", "#224C5B", BLACK], - "brown_spike_colors": ["#754C24", "#603813", "#42210b", BLACK], + "blue_spike_colors": [ + "#528EA3", + "#3E6576", + "#224C5B", + BLACK, + ], + "brown_spike_colors": [ + "#754C24", + "#603813", + "#42210b", + BLACK, + ], "n_spike_layers": 4, "n_spikes": 28, "spike_angle": TAU / 28, @@ -630,13 +657,19 @@ def add_iris_back(self): fill_opacity=1, stroke_width=0, ) - self.iris_background = VGroup(blue_iris_back, brown_iris_back) + self.iris_background = VGroup( + blue_iris_back, + brown_iris_back, + ) self.add(self.iris_background) def add_spikes(self): layers = VGroup() radii = np.linspace( - self.outer_radius, self.pupil_radius, self.n_spike_layers, endpoint=False + self.outer_radius, + self.pupil_radius, + self.n_spike_layers, + endpoint=False, ) radii[:2] = radii[1::-1] # Swap first two if self.n_spike_layers > 2: @@ -653,7 +686,10 @@ def add_spikes(self): fill_opacity=1, stroke_width=0, ) - for vertex3 in (half_base * LEFT, ORIGIN) + for vertex3 in ( + half_base * LEFT, + ORIGIN, + ) ] left_half_triangle = right_half_triangle.copy() left_half_triangle.flip(UP, about_point=ORIGIN) @@ -671,8 +707,14 @@ def add_spikes(self): else: half_spikes = [ right_half_triangle.copy(), - left_half_triangle.copy().rotate(90 * DEGREES, about_point=ORIGIN), - right_half_triangle.copy().rotate(90 * DEGREES, about_point=ORIGIN), + left_half_triangle.copy().rotate( + 90 * DEGREES, + about_point=ORIGIN, + ), + right_half_triangle.copy().rotate( + 90 * DEGREES, + about_point=ORIGIN, + ), left_half_triangle.copy(), ] layer = VGroup( @@ -820,7 +862,12 @@ def get_value(self): if value not in self.possible_values: raise Exception("Invalid card value") - face_card_to_value = {"J": 11, "Q": 12, "K": 13, "A": 14} + face_card_to_value = { + "J": 11, + "Q": 12, + "K": 13, + "A": 14, + } try: self.numerical_value = int(value) except: @@ -858,9 +905,25 @@ def get_ace_design(self, symbol): def get_number_design(self, value, symbol): num = int(value) - n_rows = {2: 2, 3: 3, 4: 2, 5: 2, 6: 3, 7: 3, 8: 3, 9: 4, 10: 4}[num] + n_rows = { + 2: 2, + 3: 3, + 4: 2, + 5: 2, + 6: 3, + 7: 3, + 8: 3, + 9: 4, + 10: 4, + }[num] n_cols = 1 if num in [2, 3] else 2 - insertion_indices = {5: [0], 7: [0], 8: [0, 1], 9: [1], 10: [0, 2]}.get(num, []) + insertion_indices = { + 5: [0], + 7: [0], + 8: [0, 1], + 9: [1], + 10: [0, 2], + }.get(num, []) top = self.get_top() + symbol.get_height() * DOWN bottom = self.get_bottom() + symbol.get_height() * UP diff --git a/manim/mobject/svg/tex_mobject.py b/manim/mobject/svg/tex_mobject.py index 272fe9500d..9cb359740f 100644 --- a/manim/mobject/svg/tex_mobject.py +++ b/manim/mobject/svg/tex_mobject.py @@ -145,7 +145,11 @@ def organize_submobjects_left_to_right(self): class MathTex(SingleStringMathTex): - CONFIG = {"arg_separator": " ", "substrings_to_isolate": [], "tex_to_color_map": {}} + CONFIG = { + "arg_separator": " ", + "substrings_to_isolate": [], + "tex_to_color_map": {}, + } def __init__(self, *tex_strings, **kwargs): digest_config(self, kwargs) @@ -250,7 +254,11 @@ def sort_alphabetically(self): class Tex(MathTex): - CONFIG = {"alignment": "\\centering", "arg_separator": "", "type": "text"} + CONFIG = { + "alignment": "\\centering", + "arg_separator": "", + "type": "text", + } class BulletedList(Tex): diff --git a/manim/mobject/svg/text_mobject.py b/manim/mobject/svg/text_mobject.py index 048d1af100..8e69b37f63 100644 --- a/manim/mobject/svg/text_mobject.py +++ b/manim/mobject/svg/text_mobject.py @@ -326,7 +326,9 @@ def text2svg(self): # Following class is just a Little implementation of upcomming feautures. Ignore it for now. class TextWithBackground(Text): - CONFIG = {"background_color": BLACK} + CONFIG = { + "background_color": BLACK, + } def __init__(self, text, **config): Text.__init__(self, text, **config) @@ -423,7 +425,10 @@ class Paragraph(VGroup): """ - CONFIG = {"line_spacing": -1, "alignment": None} + CONFIG = { + "line_spacing": -1, + "alignment": None, + } def __init__(self, *text, **config): VGroup.__init__(self, **config) diff --git a/manim/mobject/three_d_shading_utils.py b/manim/mobject/three_d_shading_utils.py index b7b7f31a74..25dc41f32e 100644 --- a/manim/mobject/three_d_shading_utils.py +++ b/manim/mobject/three_d_shading_utils.py @@ -7,7 +7,10 @@ def get_3d_vmob_gradient_start_and_end_points(vmob): - return (get_3d_vmob_start_corner(vmob), get_3d_vmob_end_corner(vmob)) + return ( + get_3d_vmob_start_corner(vmob), + get_3d_vmob_end_corner(vmob), + ) def get_3d_vmob_start_corner_index(vmob): @@ -38,7 +41,8 @@ def get_3d_vmob_unit_normal(vmob, point_index): im1 = i - 1 if i > 0 else (n_points - 2) ip1 = i + 1 if i < (n_points - 1) else 1 return get_unit_normal( - vmob.points[ip1] - vmob.points[i], vmob.points[im1] - vmob.points[i] + vmob.points[ip1] - vmob.points[i], + vmob.points[im1] - vmob.points[i], ) diff --git a/manim/mobject/three_d_utils.py b/manim/mobject/three_d_utils.py index 39e38f8a0f..ec2ee4d245 100644 --- a/manim/mobject/three_d_utils.py +++ b/manim/mobject/three_d_utils.py @@ -21,7 +21,10 @@ def get_3d_vmob_gradient_start_and_end_points(vmob): - return (get_3d_vmob_start_corner(vmob), get_3d_vmob_end_corner(vmob)) + return ( + get_3d_vmob_start_corner(vmob), + get_3d_vmob_end_corner(vmob), + ) def get_3d_vmob_start_corner_index(vmob): @@ -52,7 +55,8 @@ def get_3d_vmob_unit_normal(vmob, point_index): im3 = i - 3 if i > 2 else (n_points - 4) ip3 = i + 3 if i < (n_points - 3) else 3 unit_normal = get_unit_normal( - vmob.points[ip3] - vmob.points[i], vmob.points[im3] - vmob.points[i] + vmob.points[ip3] - vmob.points[i], + vmob.points[im3] - vmob.points[i], ) if get_norm(unit_normal) == 0: return np.array(UP) diff --git a/manim/mobject/three_dimensions.py b/manim/mobject/three_dimensions.py index 154df1ff43..748f737c49 100644 --- a/manim/mobject/three_dimensions.py +++ b/manim/mobject/three_dimensions.py @@ -8,13 +8,15 @@ from ..mobject.types.vectorized_mobject import VMobject from ..utils.iterables import tuplify from ..utils.space_ops import z_to_vector -from ..utils.color import BLUE_D, BLUE, BLUE_E, LIGHT_GREY +from ..utils.color import BLUE_D, BLUE , BLUE_E , LIGHT_GREY ############## class ThreeDVMobject(VMobject): - CONFIG = {"shade_in_3d": True} + CONFIG = { + "shade_in_3d": True, + } class ParametricSurface(VGroup): @@ -67,7 +69,13 @@ def setup_in_uv_space(self): v1, v2 = v_values[j : j + 2] face = ThreeDVMobject() face.set_points_as_corners( - [[u1, v1, 0], [u2, v1, 0], [u2, v2, 0], [u1, v2, 0], [u1, v1, 0]] + [ + [u1, v1, 0], + [u2, v1, 0], + [u2, v2, 0], + [u1, v2, 0], + [u1, v1, 0], + ] ) faces.add(face) face.u_index = i @@ -124,7 +132,10 @@ class Cube(VGroup): def generate_points(self): for vect in IN, OUT, LEFT, RIGHT, UP, DOWN: - face = Square(side_length=self.side_length, shade_in_3d=True) + face = Square( + side_length=self.side_length, + shade_in_3d=True, + ) face.flip() face.shift(self.side_length * OUT / 2.0) face.apply_matrix(z_to_vector(vect)) diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.py index 6b80030b73..a4e11136de 100644 --- a/manim/mobject/types/image_mobject.py +++ b/manim/mobject/types/image_mobject.py @@ -21,7 +21,10 @@ class AbstractImageMobject(Mobject): Automatically filters out black pixels """ - CONFIG = {"height": 2.0, "pixel_array_dtype": "uint8"} + CONFIG = { + "height": 2.0, + "pixel_array_dtype": "uint8", + } def get_pixel_array(self): raise Exception("Not implemented") @@ -32,7 +35,13 @@ def set_color(self): def reset_points(self): # Corresponding corners of image are fixed to these 3 points - self.points = np.array([UP + LEFT, UP + RIGHT, DOWN + LEFT]) + self.points = np.array( + [ + UP + LEFT, + UP + RIGHT, + DOWN + LEFT, + ] + ) self.center() h, w = self.get_pixel_array().shape[:2] self.stretch_to_fit_height(self.height) @@ -40,7 +49,10 @@ def reset_points(self): class ImageMobject(AbstractImageMobject): - CONFIG = {"invert": False, "image_mode": "RGBA"} + CONFIG = { + "invert": False, + "image_mode": "RGBA", + } def __init__(self, filename_or_array, **kwargs): digest_config(self, kwargs) diff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.py index b47c7cdacb..6c5be357cb 100644 --- a/manim/mobject/types/point_cloud_mobject.py +++ b/manim/mobject/types/point_cloud_mobject.py @@ -15,7 +15,9 @@ class PMobject(Mobject): - CONFIG = {"stroke_width": DEFAULT_STROKE_WIDTH} + CONFIG = { + "stroke_width": DEFAULT_STROKE_WIDTH, + } def reset_points(self): self.rgbas = np.zeros((0, 4)) @@ -160,7 +162,11 @@ def get_point_mobject(self, center=None): def interpolate_color(self, mobject1, mobject2, alpha): self.rgbas = interpolate(mobject1.rgbas, mobject2.rgbas, alpha) self.set_stroke_width( - interpolate(mobject1.get_stroke_width(), mobject2.get_stroke_width(), alpha) + interpolate( + mobject1.get_stroke_width(), + mobject2.get_stroke_width(), + alpha, + ) ) return self @@ -174,7 +180,9 @@ def pointwise_become_partial(self, mobject, a, b): # TODO, Make the two implementations bellow non-redundant class Mobject1D(PMobject): - CONFIG = {"density": DEFAULT_POINT_DENSITY_1D} + CONFIG = { + "density": DEFAULT_POINT_DENSITY_1D, + } def __init__(self, **kwargs): digest_config(self, kwargs) @@ -193,7 +201,9 @@ def add_line(self, start, end, color=None): class Mobject2D(PMobject): - CONFIG = {"density": DEFAULT_POINT_DENSITY_2D} + CONFIG = { + "density": DEFAULT_POINT_DENSITY_2D, + } def __init__(self, **kwargs): digest_config(self, kwargs) @@ -232,7 +242,9 @@ def generate_points(self): class Point(PMobject): - CONFIG = {"color": BLACK} + CONFIG = { + "color": BLACK, + } def __init__(self, location=ORIGIN, **kwargs): PMobject.__init__(self, **kwargs) diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index 13a875aa24..cbc63d9c85 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -79,7 +79,10 @@ def get_group_class(self): # Colors def init_colors(self): - self.set_fill(color=self.fill_color or self.color, opacity=self.fill_opacity) + self.set_fill( + color=self.fill_color or self.color, + opacity=self.fill_opacity, + ) self.set_stroke( color=self.stroke_color or self.color, width=self.stroke_width, @@ -90,7 +93,10 @@ def init_colors(self): width=self.background_stroke_width, opacity=self.background_stroke_opacity, ) - self.set_sheen(factor=self.sheen_factor, direction=self.sheen_direction) + self.set_sheen( + factor=self.sheen_factor, + direction=self.sheen_direction, + ) return self def generate_rgbas_array(self, color, opacity): @@ -197,7 +203,9 @@ def set_style( ) if sheen_factor: self.set_sheen( - factor=sheen_factor, direction=sheen_direction, family=family + factor=sheen_factor, + direction=sheen_direction, + family=family, ) if background_image_file: self.color_using_background_image(background_image_file) @@ -246,10 +254,17 @@ def set_opacity(self, opacity, family=True): def fade(self, darkness=0.5, family=True): factor = 1.0 - darkness - self.set_fill(opacity=factor * self.get_fill_opacity(), family=False) - self.set_stroke(opacity=factor * self.get_stroke_opacity(), family=False) + self.set_fill( + opacity=factor * self.get_fill_opacity(), + family=False, + ) + self.set_stroke( + opacity=factor * self.get_stroke_opacity(), + family=False, + ) self.set_background_stroke( - opacity=factor * self.get_stroke_opacity(background=True), family=False + opacity=factor * self.get_stroke_opacity(background=True), + family=False, ) super().fade(darkness, family) return self @@ -665,7 +680,14 @@ def get_anchors(self): if self.points.shape[0] == 1: return self.points return np.array( - list(it.chain(*zip(self.get_start_anchors(), self.get_end_anchors()))) + list( + it.chain( + *zip( + self.get_start_anchors(), + self.get_end_anchors(), + ) + ) + ) ) def get_points_defining_boundary(self): diff --git a/manim/mobject/vector_field.py b/manim/mobject/vector_field.py index b1a1a0446e..7ac3e439dd 100644 --- a/manim/mobject/vector_field.py +++ b/manim/mobject/vector_field.py @@ -42,7 +42,10 @@ DEFAULT_SCALAR_FIELD_COLORS = [BLUE_E, GREEN, YELLOW, RED] -def get_colored_background_image(scalar_field_func, number_to_rgb_func): +def get_colored_background_image( + scalar_field_func, + number_to_rgb_func, +): ph = config["pixel_height"] pw = config["pixel_width"] fw = config["frame_width"] @@ -63,7 +66,10 @@ def get_colored_background_image(scalar_field_func, number_to_rgb_func): def get_rgb_gradient_function( - min_value=0, max_value=1, colors=[BLUE, RED], flip_alphas=True # Why? + min_value=0, + max_value=1, + colors=[BLUE, RED], + flip_alphas=True, # Why? ): rgbs = np.array(list(map(color_to_rgb, colors))) @@ -234,7 +240,9 @@ def __init__(self, func, **kwargs): if self.color_by_arc_length: len_to_rgb = get_rgb_gradient_function( - self.min_arc_length, self.max_arc_length, colors=self.colors + self.min_arc_length, + self.max_arc_length, + colors=self.colors, ) for line in self: arc_length = line.get_arc_length() @@ -304,7 +312,11 @@ class AnimatedStreamLines(VGroup): CONFIG = { "lag_range": 4, "line_anim_class": ShowPassingFlash, - "line_anim_config": {"run_time": 4, "rate_func": linear, "time_width": 0.3}, + "line_anim_config": { + "run_time": 4, + "rate_func": linear, + "time_width": 0.3, + }, } def __init__(self, stream_lines, **kwargs): diff --git a/manim/scene/reconfigurable_scene.py b/manim/scene/reconfigurable_scene.py index 6d322e48ad..7f5d3c21d9 100644 --- a/manim/scene/reconfigurable_scene.py +++ b/manim/scene/reconfigurable_scene.py @@ -11,7 +11,9 @@ class ReconfigurableScene(Scene): Note, this seems to no longer work as intented. """ - CONFIG = {"allow_recursion": True} + CONFIG = { + "allow_recursion": True, + } def setup(self): self.states = [] diff --git a/manim/scene/scene.py b/manim/scene/scene.py index 5babbbeece..e3f9925519 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -65,7 +65,10 @@ def construct(self): def __init__(self, **kwargs): Container.__init__(self, **kwargs) self.camera = self.camera_class(**camera_config) - self.file_writer = SceneFileWriter(self, **file_writer_config) + self.file_writer = SceneFileWriter( + self, + **file_writer_config, + ) self.play_hashes_list = [] self.mobjects = [] self.original_skipping_status = file_writer_config["skip_animations"] @@ -196,7 +199,10 @@ def update_frame( # TODO Description in Docstring if file_writer_config["skip_animations"] and not ignore_skipping: return if mobjects is None: - mobjects = list_update(self.mobjects, self.foreground_mobjects) + mobjects = list_update( + self.mobjects, + self.foreground_mobjects, + ) if background is not None: self.camera.set_pixel_array(background) else: @@ -713,7 +719,11 @@ def compile_play_args_to_animation_list(self, *args, **kwargs): list : list of animations with the parameters applied to them. """ animations = [] - state = {"curr_method": None, "last_method": None, "method_args": []} + state = { + "curr_method": None, + "last_method": None, + "method_args": [], + } def compile_method(state): if state["curr_method"] is None: diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py index d20d81af9a..e510c351da 100644 --- a/manim/scene/scene_file_writer.py +++ b/manim/scene/scene_file_writer.py @@ -61,7 +61,10 @@ def init_output_directories(self): if file_writer_config["media_dir"] != "": if not file_writer_config["custom_folders"]: image_dir = guarantee_existence( - os.path.join(file_writer_config["images_dir"], module_directory) + os.path.join( + file_writer_config["images_dir"], + module_directory, + ) ) else: image_dir = guarantee_existence(file_writer_config["images_dir"]) @@ -94,7 +97,11 @@ def init_output_directories(self): ) if not file_writer_config["custom_folders"]: self.partial_movie_directory = guarantee_existence( - os.path.join(movie_dir, "partial_movie_files", scene_name) + os.path.join( + movie_dir, + "partial_movie_files", + scene_name, + ) ) else: self.partial_movie_directory = guarantee_existence( @@ -257,7 +264,8 @@ def add_audio_segment(self, new_segment, time=None, gain_to_background=None): diff = new_end - curr_end if diff > 0: segment = segment.append( - AudioSegment.silent(int(np.ceil(diff * 1000))), crossfade=0 + AudioSegment.silent(int(np.ceil(diff * 1000))), + crossfade=0, ) self.audio_segment = segment.overlay( new_segment, @@ -426,9 +434,17 @@ def open_movie_pipe(self): if file_writer_config["movie_file_extension"] == ".mov": # This is if the background of the exported # video should be transparent. - command += ["-vcodec", "qtrle"] + command += [ + "-vcodec", + "qtrle", + ] else: - command += ["-vcodec", "libx264", "-pix_fmt", "yuv420p"] + command += [ + "-vcodec", + "libx264", + "-pix_fmt", + "yuv420p", + ] command += [temp_file_path] self.writing_process = subprocess.Popen(command, stdin=subprocess.PIPE) @@ -440,7 +456,10 @@ def close_movie_pipe(self): """ self.writing_process.stdin.close() self.writing_process.wait() - shutil.move(self.temp_partial_movie_file_path, self.partial_movie_file_path) + shutil.move( + self.temp_partial_movie_file_path, + self.partial_movie_file_path, + ) logger.info( f"Animation {self.scene.num_plays} : Partial movie file written in %(path)s", {"path": {self.partial_movie_file_path}}, @@ -531,7 +550,10 @@ def combine_movie_files(self): ) # Makes sure sound file length will match video file self.add_audio_segment(AudioSegment.silent(0)) - self.audio_segment.export(sound_file_path, bitrate="312k") + self.audio_segment.export( + sound_file_path, + bitrate="312k", + ) temp_file_path = movie_file_path.replace(".", "_temp.") commands = [ FFMPEG_BIN, diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py index 8303967821..5d0f187201 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -515,9 +515,16 @@ class LinearTransformationScene(VectorScene): "include_foreground_plane": True, "background_plane_kwargs": { "color": GREY, - "axis_config": {"stroke_color": LIGHT_GREY}, - "axis_config": {"color": GREY}, - "background_line_style": {"stroke_color": GREY, "stroke_width": 1}, + "axis_config": { + "stroke_color": LIGHT_GREY, + }, + "axis_config": { + "color": GREY, + }, + "background_line_style": { + "stroke_color": GREY, + "stroke_width": 1, + }, }, "show_coordinates": False, "show_basis_vectors": True, @@ -562,7 +569,8 @@ def setup(self): self.add_transformable_mobject(self.plane) if self.show_basis_vectors: self.basis_vectors = self.get_basis_vectors( - i_hat_color=self.i_hat_color, j_hat_color=self.j_hat_color + i_hat_color=self.i_hat_color, + j_hat_color=self.j_hat_color, ) self.moving_vectors += list(self.basis_vectors) self.i_hat, self.j_hat = self.basis_vectors diff --git a/manim/scene/zoomed_scene.py b/manim/scene/zoomed_scene.py index a2583a2e36..acbf1997fd 100644 --- a/manim/scene/zoomed_scene.py +++ b/manim/scene/zoomed_scene.py @@ -85,7 +85,10 @@ def activate_zooming(self, animate=False): if animate: self.play(self.get_zoom_in_animation()) self.play(self.get_zoomed_display_pop_out_animation()) - self.add_foreground_mobjects(self.zoomed_camera.frame, self.zoomed_display) + self.add_foreground_mobjects( + self.zoomed_camera.frame, + self.zoomed_display, + ) def get_zoom_in_animation(self, run_time=2, **kwargs): """ diff --git a/manim/utils/color.py b/manim/utils/color.py index 18cb6d1eb5..04cbe2cbf0 100644 --- a/manim/utils/color.py +++ b/manim/utils/color.py @@ -186,7 +186,7 @@ class Colors(Enum): BLUE_E = Colors.blue_e.value BLUE_D = Colors.blue_d.value BLUE_C = Colors.blue_c.value -BLUE = Colors.blue.value +BLUE = Colors.blue.value BLUE_B = Colors.blue_b.value BLUE_A = Colors.blue_a.value TEAL_E = Colors.teal_e.value @@ -280,7 +280,7 @@ def hex_to_rgb(hex_code): hex_part = hex_code[1:] if len(hex_part) == 3: "".join([2 * c for c in hex_part]) - return np.array([int(hex_part[i : i + 2], 16) / 255 for i in range(0, 6, 2)]) + return np.array([int(hex_part[i: i + 2], 16) / 255 for i in range(0, 6, 2)]) def invert_color(color): @@ -332,11 +332,9 @@ def random_bright_color(): def random_color(): import time - random.seed(time.time()) return random.choice([c.value for c in list(Colors)]) - def get_shaded_rgb(rgb, point, unit_normal_vect, light_source): to_sun = normalize(light_source - point) factor = 0.5 * np.dot(unit_normal_vect, to_sun) ** 3 @@ -344,4 +342,4 @@ def get_shaded_rgb(rgb, point, unit_normal_vect, light_source): factor *= 0.5 result = rgb + factor clip_in_place(rgb + factor, 0, 1) - return result + return result \ No newline at end of file diff --git a/manim/utils/paths.py b/manim/utils/paths.py index e655977b6f..addaa84b96 100644 --- a/manim/utils/paths.py +++ b/manim/utils/paths.py @@ -1,6 +1,11 @@ """Functions determining transformation paths between sets of points.""" -__all__ = ["straight_path", "path_along_arc", "clockwise_path", "counterclockwise_path"] +__all__ = [ + "straight_path", + "path_along_arc", + "clockwise_path", + "counterclockwise_path", +] import numpy as np diff --git a/manim/utils/rate_functions.py b/manim/utils/rate_functions.py index 24ce770a18..dfd1a0c4d0 100644 --- a/manim/utils/rate_functions.py +++ b/manim/utils/rate_functions.py @@ -30,7 +30,11 @@ def linear(t): def smooth(t, inflection=10.0): error = sigmoid(-inflection / 2) - return np.clip((sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error), 0, 1) + return np.clip( + (sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error), + 0, + 1, + ) def rush_into(t, inflection=10.0): diff --git a/manim/utils/sounds.py b/manim/utils/sounds.py index 92ecb8cac7..dd46294d99 100644 --- a/manim/utils/sounds.py +++ b/manim/utils/sounds.py @@ -14,7 +14,13 @@ def play_chord(*nums): commands = ( - ["play", "-n", "-c1", "--no-show-progress", "synth"] + [ + "play", + "-n", + "-c1", + "--no-show-progress", + "synth", + ] + ["sin %-" + str(num) for num in nums] + ["fade h 0.5 1 0.5", ">", os.devnull] ) diff --git a/tests/helpers/video_utils.py b/tests/helpers/video_utils.py index 218327789d..5b7aa2791f 100644 --- a/tests/helpers/video_utils.py +++ b/tests/helpers/video_utils.py @@ -9,7 +9,10 @@ def capture(command): proc = subprocess.Popen( - command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8" + command, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf8", ) out, err = proc.communicate() return out, err, proc.returncode @@ -47,7 +50,10 @@ def save_control_data_from_video(path_to_video, name): tests_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) path_control_data = os.path.join(tests_directory, "control_data", "videos_data") config_video = get_config_from_video(path_to_video) - data = {"name": name, "config": json.loads(config_video)["streams"][0]} + data = { + "name": name, + "config": json.loads(config_video)["streams"][0], + } path_saved = os.path.join(path_control_data, f"{name}.json") json.dump(data, open(path_saved, "w"), indent=4) logger.info(f"Data for {name} saved in {path_saved}") diff --git a/tests/test_family.py b/tests/test_family.py index f9747cf000..47744cbb43 100644 --- a/tests/test_family.py +++ b/tests/test_family.py @@ -37,7 +37,11 @@ def test_family(): def test_overlapping_family(): """Check that each member of the family is only gathered once.""" - mob, child1, child2, = (Mobject(), Mobject(), Mobject()) + mob, child1, child2, = ( + Mobject(), + Mobject(), + Mobject(), + ) gchild1, gchild2, gchild_common = Mobject(), Mobject(), Mobject() child1.add(gchild1, gchild_common) child2.add(gchild2, gchild_common) @@ -57,7 +61,11 @@ def test_shift_family(): """ # Note shift() needs the mobject to have a non-empty `points` attribute, so # we cannot use a plain Mobject or VMobject. We use Circle instead. - mob, child1, child2, = (Circle(), Circle(), Circle()) + mob, child1, child2, = ( + Circle(), + Circle(), + Circle(), + ) gchild1, gchild2, gchild_common = Circle(), Circle(), Circle() child1.add(gchild1, gchild_common) diff --git a/tests/test_logging/basic_scenes.py b/tests/test_logging/basic_scenes.py index d1bd250da7..3f190f36e8 100644 --- a/tests/test_logging/basic_scenes.py +++ b/tests/test_logging/basic_scenes.py @@ -11,7 +11,9 @@ def construct(self): class WriteStuff(Scene): def construct(self): example_text = Tex("This is a some text", tex_to_color_map={"text": YELLOW}) - example_tex = MathTex("\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}") + example_tex = MathTex( + "\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}", + ) group = VGroup(example_text, example_tex) group.arrange(DOWN) group.set_width(config["frame_width"] - 2 * LARGE_BUFF) diff --git a/tests/utils/GraphicalUnitTester.py b/tests/utils/GraphicalUnitTester.py index 5dc77e8a55..ef8cb4e373 100644 --- a/tests/utils/GraphicalUnitTester.py +++ b/tests/utils/GraphicalUnitTester.py @@ -32,7 +32,12 @@ class GraphicalUnitTester: The scene tested """ - def __init__(self, scene_object, module_tested, tmpdir): + def __init__( + self, + scene_object, + module_tested, + tmpdir, + ): # Disable the the logs, (--quiet is broken) TODO logging.disable(logging.CRITICAL) tests_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/tests/utils/commands.py b/tests/utils/commands.py index 5414b56ce5..90c5d3caf1 100644 --- a/tests/utils/commands.py +++ b/tests/utils/commands.py @@ -3,7 +3,10 @@ def capture(command): proc = subprocess.Popen( - command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8" + command, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf8", ) out, err = proc.communicate() return out, err, proc.returncode From 08033cfdc4e9af9ca63dc4212e45e43c6d801970 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 15:54:08 +0200 Subject: [PATCH 09/13] # run black only on color.py --- manim/utils/color.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/manim/utils/color.py b/manim/utils/color.py index 04cbe2cbf0..18cb6d1eb5 100644 --- a/manim/utils/color.py +++ b/manim/utils/color.py @@ -186,7 +186,7 @@ class Colors(Enum): BLUE_E = Colors.blue_e.value BLUE_D = Colors.blue_d.value BLUE_C = Colors.blue_c.value -BLUE = Colors.blue.value +BLUE = Colors.blue.value BLUE_B = Colors.blue_b.value BLUE_A = Colors.blue_a.value TEAL_E = Colors.teal_e.value @@ -280,7 +280,7 @@ def hex_to_rgb(hex_code): hex_part = hex_code[1:] if len(hex_part) == 3: "".join([2 * c for c in hex_part]) - return np.array([int(hex_part[i: i + 2], 16) / 255 for i in range(0, 6, 2)]) + return np.array([int(hex_part[i : i + 2], 16) / 255 for i in range(0, 6, 2)]) def invert_color(color): @@ -332,9 +332,11 @@ def random_bright_color(): def random_color(): import time + random.seed(time.time()) return random.choice([c.value for c in list(Colors)]) + def get_shaded_rgb(rgb, point, unit_normal_vect, light_source): to_sun = normalize(light_source - point) factor = 0.5 * np.dot(unit_normal_vect, to_sun) ** 3 @@ -342,4 +344,4 @@ def get_shaded_rgb(rgb, point, unit_normal_vect, light_source): factor *= 0.5 result = rgb + factor clip_in_place(rgb + factor, 0, 1) - return result \ No newline at end of file + return result From ab718e43dadf41e52cf94d6d676f745be13e4c68 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Tue, 29 Sep 2020 16:51:40 +0200 Subject: [PATCH 10/13] Update manim/utils/color.py Co-authored-by: Leo Torres --- manim/utils/color.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/manim/utils/color.py b/manim/utils/color.py index 18cb6d1eb5..f0d88666be 100644 --- a/manim/utils/color.py +++ b/manim/utils/color.py @@ -97,19 +97,25 @@ class Colors(Enum): """A list of pre-defined colors. + Examples -------- The preferred way of using these colors is + .. code-block:: python import manim.utils.color as C C.WHITE # -> '#FFFFFF' - Note this way uses the name of the colors below in UPPERCASE. + + Note this way uses the name of the colors in UPPERCASE. + Alternatively, you can also import this Enum directly and use its members directly, through the use of :code:`color.value`. Note this way uses the name of the colors in lowercase. + .. code-block:: python from manim.utils.color import Colors Colors.white.value # -> '#FFFFFF' + """ dark_blue = "#236B8E" From 60e8fd04720097665458f92f4eac65e4d76a07d4 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Tue, 29 Sep 2020 16:52:35 +0200 Subject: [PATCH 11/13] enable custom seed --- manim/utils/color.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/manim/utils/color.py b/manim/utils/color.py index f0d88666be..2dabb9c641 100644 --- a/manim/utils/color.py +++ b/manim/utils/color.py @@ -337,9 +337,6 @@ def random_bright_color(): def random_color(): - import time - - random.seed(time.time()) return random.choice([c.value for c in list(Colors)]) From d00f4db79d56168d198f56119f0c1ea97ecad2c4 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 17:00:19 +0200 Subject: [PATCH 12/13] Added Colors have moved to an Enum to changelog --- docs/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index dc06363cb2..85fdd00ce3 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -92,6 +92,7 @@ Of interest to developers #. Added logging tests tools. #. Added ability to save logs in json #. Move to Poetry. +#. Colors have moved to an Enum Other Changes -------------- From d2b1d730bd1465f8bf608ebc1a18c62ca888aaa7 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Tue, 29 Sep 2020 17:42:33 +0200 Subject: [PATCH 13/13] added color test --- tests/test_color.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/test_color.py diff --git a/tests/test_color.py b/tests/test_color.py new file mode 100644 index 0000000000..f6cb672bb4 --- /dev/null +++ b/tests/test_color.py @@ -0,0 +1,6 @@ +import pytest +from manim import Camera, tempconfig, config + +def test_import_color(): + import manim.utils.color as C + C.WHITE \ No newline at end of file