From bf13321d5df05e6572e491439653f75953eb11ff Mon Sep 17 00:00:00 2001 From: leotrs Date: Thu, 29 Oct 2020 22:27:13 -0400 Subject: [PATCH 1/7] start here --- manim/mobject/mobject.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 5a34582183..e84691ab95 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -42,15 +42,19 @@ class Mobject(Container): """ - CONFIG = { - "color": WHITE, - "name": None, - "dim": 3, - "target": None, - "z_index": 0, - } - - def __init__(self, **kwargs): + def __init__( + self, + color=WHITE, + name=None, + dim=3, + target=None, + z_index=0, + **kwargs): + self.color = color + self.name = name + self.dim = dim + self.target = target + self.z_index = z_index Container.__init__(self, **kwargs) self.point_hash = None self.submobjects = [] From 247dd184d80e43b19e8ab264b89b4472cb1f9a25 Mon Sep 17 00:00:00 2001 From: leotrs Date: Thu, 29 Oct 2020 22:35:52 -0400 Subject: [PATCH 2/7] get rid of color --- manim/mobject/geometry.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index bc06db8b5c..c74205ffd4 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -376,10 +376,10 @@ def __init__(self, start_point, end_point, **kwargs): class Circle(Arc): - CONFIG = {"color": RED, "close_new_points": True, "anchors_span_full_range": False} + CONFIG = {"close_new_points": True, "anchors_span_full_range": False} - def __init__(self, **kwargs): - Arc.__init__(self, 0, TAU, **kwargs) + def __init__(self, color=RED, **kwargs): + Arc.__init__(self, 0, TAU, color=color, **kwargs) def surround(self, mobject, dim_to_match=0, stretch=False, buffer_factor=1.2): # Ignores dim_to_match and stretch; result will always be a circle @@ -402,11 +402,10 @@ class Dot(Circle): "radius": DEFAULT_DOT_RADIUS, "stroke_width": 0, "fill_opacity": 1.0, - "color": WHITE, } - def __init__(self, point=ORIGIN, **kwargs): - Circle.__init__(self, arc_center=point, **kwargs) + def __init__(self, point=ORIGIN, color=WHITE, **kwargs): + Circle.__init__(self, arc_center=point, color=color, **kwargs) class SmallDot(Dot): @@ -432,9 +431,11 @@ class AnnularSector(Arc): "start_angle": 0, "fill_opacity": 1, "stroke_width": 0, - "color": WHITE, } + def __init__(self, color=WHITE, **kwargs): + Arc.__init__(self, color=color, **kwargs) + def generate_points(self): inner_arc, outer_arc = [ Arc( @@ -462,10 +463,12 @@ class Annulus(Circle): "outer_radius": 2, "fill_opacity": 1, "stroke_width": 0, - "color": WHITE, "mark_paths_closed": False, } + def __init__(self, color=WHITE, **kwargs): + Circle.__init__(self, color=color, **kwargs) + def generate_points(self): self.radius = self.outer_radius outer_circle = Circle(radius=self.outer_radius) @@ -773,12 +776,9 @@ def __init__(self, points, **kwargs): class Polygon(VMobject): - CONFIG = { - "color": BLUE, - } - def __init__(self, *vertices, **kwargs): - VMobject.__init__(self, **kwargs) + def __init__(self, *vertices, color=BLUE, **kwargs): + VMobject.__init__(self, color=color, **kwargs) self.set_points_as_corners([*vertices, vertices[0]]) def get_vertices(self): @@ -843,15 +843,14 @@ def __init__(self, **kwargs): class Rectangle(Polygon): CONFIG = { - "color": WHITE, "height": 2.0, "width": 4.0, "mark_paths_closed": True, "close_new_points": True, } - def __init__(self, **kwargs): - Polygon.__init__(self, UL, UR, DR, DL, **kwargs) + def __init__(self, color=WHITE, **kwargs): + Polygon.__init__(self, UL, UR, DR, DL, color=color, **kwargs) self.set_width(self.width, stretch=True) self.set_height(self.height, stretch=True) From 176b452832efe962e94207fddb8e914bbf907d23 Mon Sep 17 00:00:00 2001 From: leotrs Date: Thu, 29 Oct 2020 22:45:03 -0400 Subject: [PATCH 3/7] get rid of some more CONFIG options --- manim/mobject/geometry.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index c74205ffd4..da5dc50013 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -843,38 +843,30 @@ def __init__(self, **kwargs): class Rectangle(Polygon): CONFIG = { - "height": 2.0, - "width": 4.0, "mark_paths_closed": True, "close_new_points": True, } - def __init__(self, color=WHITE, **kwargs): - Polygon.__init__(self, UL, UR, DR, DL, color=color, **kwargs) + def __init__(self, height=2.0, width=4.0, color=WHITE, **kwargs): + Polygon.__init__(self, UL, UR, DR, DL, height=height, width=width, color=color, **kwargs) self.set_width(self.width, stretch=True) self.set_height(self.height, stretch=True) class Square(Rectangle): - CONFIG = { - "side_length": 2.0, - } - def __init__(self, **kwargs): - digest_config(self, kwargs) + def __init__(self, side_length=2.0, **kwargs): + self.side_length = side_length Rectangle.__init__( self, height=self.side_length, width=self.side_length, **kwargs ) class RoundedRectangle(Rectangle): - CONFIG = { - "corner_radius": 0.5, - } - def __init__(self, **kwargs): - Rectangle.__init__(self, **kwargs) - self.round_corners(self.corner_radius) + def __init__(self, corner_radius=0.5, **kwargs): + Rectangle.__init__(self, corner_radius=corner_radius, **kwargs) + self.round_corners(corner_radius) class ArrowTip(VMobject): From 3f6c72935bb8961f9bfb7e36e313a71388246806 Mon Sep 17 00:00:00 2001 From: leotrs Date: Thu, 29 Oct 2020 23:44:35 -0400 Subject: [PATCH 4/7] bye bye config --- manim/mobject/geometry.py | 97 ++++++++----------- manim/mobject/mobject.py | 9 +- manim/mobject/types/vectorized_mobject.py | 5 - .../test_caching_related.py | 2 + 4 files changed, 46 insertions(+), 67 deletions(-) diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index da5dc50013..e92810657e 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -236,17 +236,16 @@ class Arc(TipableVMobject): """A circular arc.""" CONFIG = { - "radius": 1.0, "num_components": 9, - "anchors_span_full_range": True, "arc_center": ORIGIN, } - def __init__(self, start_angle=0, angle=TAU / 4, **kwargs): + def __init__(self, start_angle=0, angle=TAU / 4, radius=1.0, **kwargs): + self.radius = radius self.start_angle = start_angle self.angle = angle self._failed_to_get_center = False - VMobject.__init__(self, **kwargs) + VMobject.__init__(self, radius=radius, **kwargs) def generate_points(self): self.set_pre_positioned_points() @@ -320,9 +319,7 @@ def stop_angle(self): class ArcBetweenPoints(Arc): - """ - Inherits from Arc and additionally takes 2 points between which the arc is spanned. - """ + """Circle arc spanning two points.""" def __init__(self, start, end, angle=TAU / 4, radius=None, **kwargs): if radius is not None: @@ -340,12 +337,10 @@ 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, radius=radius, **kwargs) + else: + Arc.__init__(self, angle=angle, radius=1.0, **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) @@ -376,8 +371,6 @@ def __init__(self, start_point, end_point, **kwargs): class Circle(Arc): - CONFIG = {"close_new_points": True, "anchors_span_full_range": False} - def __init__(self, color=RED, **kwargs): Arc.__init__(self, 0, TAU, color=color, **kwargs) @@ -399,42 +392,38 @@ def point_at_angle(self, angle): class Dot(Circle): CONFIG = { - "radius": DEFAULT_DOT_RADIUS, "stroke_width": 0, "fill_opacity": 1.0, } - def __init__(self, point=ORIGIN, color=WHITE, **kwargs): - Circle.__init__(self, arc_center=point, color=color, **kwargs) + def __init__(self, point=ORIGIN, radius=DEFAULT_DOT_RADIUS, color=WHITE, **kwargs): + Circle.__init__(self, arc_center=point, radius=radius, color=color, **kwargs) class SmallDot(Dot): - CONFIG = { - "radius": DEFAULT_SMALL_DOT_RADIUS, - } + def __init__(self, radius=DEFAULT_SMALL_DOT_RADIUS, **kwargs): + Circle.__init__(self, radius=radius, **kwargs) class Ellipse(Circle): - CONFIG = {"width": 2, "height": 1} - - def __init__(self, **kwargs): - Circle.__init__(self, **kwargs) - self.set_width(self.width, stretch=True) - self.set_height(self.height, stretch=True) + def __init__(self, width=2.0, height=1.0, **kwargs): + self.width = width + self.height = height + Circle.__init__(self, width=width, height=height, **kwargs) + self.set_width(width, stretch=True) + self.set_height(height, stretch=True) class AnnularSector(Arc): CONFIG = { - "inner_radius": 1, - "outer_radius": 2, "angle": TAU / 4, "start_angle": 0, "fill_opacity": 1, "stroke_width": 0, } - def __init__(self, color=WHITE, **kwargs): - Arc.__init__(self, color=color, **kwargs) + def __init__(self, outer_radius=2.0, inner_radius=1.0, color=WHITE, **kwargs): + Arc.__init__(self, outer_radius=outer_radius, inner_radius=inner_radius, color=color, **kwargs) def generate_points(self): inner_arc, outer_arc = [ @@ -454,20 +443,30 @@ def generate_points(self): class Sector(AnnularSector): - CONFIG = {"outer_radius": 1, "inner_radius": 0} + def __init__(self, outer_radius=1.0, inner_radius=0.0, color=WHITE, **kwargs): + AnnularSector.__init__( + self, + outer_radius=outer_radius, + inner_radius=inner_radius, + color=color, + **kwargs + ) class Annulus(Circle): CONFIG = { - "inner_radius": 1, - "outer_radius": 2, "fill_opacity": 1, "stroke_width": 0, - "mark_paths_closed": False, } - def __init__(self, color=WHITE, **kwargs): - Circle.__init__(self, color=color, **kwargs) + def __init__(self, outer_radius=2.0, inner_radius=1.0, color=WHITE, **kwargs): + Circle.__init__( + self, + outer_radius=outer_radius, + inner_radius=inner_radius, + color=color, + **kwargs + ) def generate_points(self): self.radius = self.outer_radius @@ -748,14 +747,12 @@ def set_stroke_width_from_length(self): class Vector(Arrow): - CONFIG = { - "buff": 0, - } - def __init__(self, direction=RIGHT, **kwargs): + def __init__(self, direction=RIGHT, buff=0, **kwargs): + self.buff = buff if len(direction) == 2: direction = np.append(np.array(direction), 0) - Arrow.__init__(self, ORIGIN, direction, **kwargs) + Arrow.__init__(self, ORIGIN, direction, buff=buff, **kwargs) class DoubleArrow(Arrow): @@ -776,7 +773,6 @@ def __init__(self, points, **kwargs): class Polygon(VMobject): - def __init__(self, *vertices, color=BLUE, **kwargs): VMobject.__init__(self, color=color, **kwargs) self.set_points_as_corners([*vertices, vertices[0]]) @@ -820,11 +816,8 @@ def round_corners(self, radius=0.5): class RegularPolygon(Polygon): - CONFIG = { - "start_angle": None, - } - - def __init__(self, n=6, **kwargs): + def __init__(self, n=6, start_angle=None, **kwargs): + self.start_angle = start_angle digest_config(self, kwargs, locals()) if self.start_angle is None: if n % 2 == 0: @@ -842,19 +835,16 @@ def __init__(self, **kwargs): class Rectangle(Polygon): - CONFIG = { - "mark_paths_closed": True, - "close_new_points": True, - } def __init__(self, height=2.0, width=4.0, color=WHITE, **kwargs): - Polygon.__init__(self, UL, UR, DR, DL, height=height, width=width, color=color, **kwargs) + Polygon.__init__( + self, UL, UR, DR, DL, height=height, width=width, color=color, **kwargs + ) self.set_width(self.width, stretch=True) self.set_height(self.height, stretch=True) class Square(Rectangle): - def __init__(self, side_length=2.0, **kwargs): self.side_length = side_length Rectangle.__init__( @@ -863,7 +853,6 @@ def __init__(self, side_length=2.0, **kwargs): class RoundedRectangle(Rectangle): - def __init__(self, corner_radius=0.5, **kwargs): Rectangle.__init__(self, corner_radius=corner_radius, **kwargs) self.round_corners(corner_radius) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index e84691ab95..dc6727730f 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -42,14 +42,7 @@ class Mobject(Container): """ - def __init__( - self, - color=WHITE, - name=None, - dim=3, - target=None, - z_index=0, - **kwargs): + def __init__(self, color=WHITE, name=None, dim=3, target=None, z_index=0, **kwargs): self.color = color self.name = name self.dim = dim diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index 8f7546cfe7..5cfe5395d3 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -34,8 +34,6 @@ # TODO # - Change cubic curve groups to have 4 points instead of 3 # - Change sub_path idea accordingly -# - No more mark_paths_closed, instead have the camera test -# if last point in close to first point # - Think about length of self.points. Always 0 or 1 mod 4? # That's kind of weird. @@ -59,9 +57,6 @@ class VMobject(Mobject): # secondary color in the direction of sheen_direction. "sheen_factor": 0.0, "sheen_direction": UL, - # Indicates that it will not be displayed, but - # that it should count in parent mobject's path - "close_new_points": False, "pre_function_handle_to_anchor_scale_factor": 0.01, "make_smooth_after_applying_functions": False, "background_image_file": None, diff --git a/tests/test_scene_rendering/test_caching_related.py b/tests/test_scene_rendering/test_caching_related.py index 03395571ab..2d7ddc7084 100644 --- a/tests/test_scene_rendering/test_caching_related.py +++ b/tests/test_scene_rendering/test_caching_related.py @@ -6,6 +6,7 @@ from ..utils.video_tester import * +@pytest.mark.slow @video_comparison( "SceneWithMultipleWaitCallsWithNFlag.json", "videos/simple_scenes/480p15/SceneWithMultipleWaitCalls.mp4", @@ -29,6 +30,7 @@ def test_wait_skip(tmp_path, manim_cfg_file, simple_scenes_path): assert exit_code == 0, err +@pytest.mark.slow @video_comparison( "SceneWithMultiplePlayCallsWithNFlag.json", "videos/simple_scenes/480p15/SceneWithMultipleCalls.mp4", From d617376169173525f9b58bf2eee675223e1d7706 Mon Sep 17 00:00:00 2001 From: leotrs Date: Fri, 30 Oct 2020 16:51:05 -0400 Subject: [PATCH 5/7] more tests and fewer CONFIGS --- manim/mobject/geometry.py | 108 ++++++++++-------- .../geometry/ArrowTest.npz | Bin 0 -> 2239 bytes .../geometry/CustomDashedLineTest.npz | Bin 0 -> 2255 bytes .../geometry/DashedLineTest.npz | Bin 0 -> 2246 bytes .../geometry/SmallDotTest.npz | Bin 0 -> 2033 bytes tests/test_graphical_units/test_geometry.py | 48 +++++++- 6 files changed, 108 insertions(+), 48 deletions(-) create mode 100644 tests/control_data/graphical_units_data/geometry/ArrowTest.npz create mode 100644 tests/control_data/graphical_units_data/geometry/CustomDashedLineTest.npz create mode 100644 tests/control_data/graphical_units_data/geometry/DashedLineTest.npz create mode 100644 tests/control_data/graphical_units_data/geometry/SmallDotTest.npz diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index 816efc89a2..e94fb0f77e 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -232,17 +232,21 @@ def get_length(self): class Arc(TipableVMobject): """A circular arc.""" - CONFIG = { - "num_components": 9, - "arc_center": ORIGIN, - } - - def __init__(self, start_angle=0, angle=TAU / 4, radius=1.0, **kwargs): + def __init__( + self, + num_components=9, + arc_center=ORIGIN, + start_angle=0, + angle=TAU/4, + radius=1.0, + **kwargs): + self.num_components = num_components + self.arc_center = arc_center self.radius = radius self.start_angle = start_angle self.angle = angle self._failed_to_get_center = False - VMobject.__init__(self, radius=radius, **kwargs) + VMobject.__init__(self, num_components=num_components, arc_center=arc_center, radius=radius, **kwargs) def generate_points(self): self.set_pre_positioned_points() @@ -359,7 +363,7 @@ def __init__(self, start_point, end_point, **kwargs): class Circle(Arc): def __init__(self, color=RED, **kwargs): - Arc.__init__(self, 0, TAU, color=color, **kwargs) + Arc.__init__(self, start_angle=0, angle=TAU, color=color, **kwargs) def surround(self, mobject, dim_to_match=0, stretch=False, buffer_factor=1.2): # Ignores dim_to_match and stretch; result will always be a circle @@ -391,19 +395,21 @@ class SmallDot(Dot): """A dot with small radius.""" def __init__(self, radius=DEFAULT_SMALL_DOT_RADIUS, **kwargs): - Circle.__init__(self, radius=radius, **kwargs) + Dot.__init__(self, radius=radius, **kwargs) class AnnotationDot(Dot): """A dot with big radius and bold stroke to annotate scenes.""" CONFIG = { - "radius": DEFAULT_DOT_RADIUS * 1.3, "stroke_width": 5, "stroke_color": WHITE, "fill_color": BLUE, } + def __init__(self, radius=DEFAULT_DOT_RADIUS * 1.3, **kwargs): + Dot.__init__(self, radius=radius, **kwargs) + class LabeledDot(Dot): """A :class:`Dot` containing a label in its center. @@ -469,14 +475,22 @@ def __init__(self, width=2.0, height=1.0, **kwargs): class AnnularSector(Arc): CONFIG = { - "angle": TAU / 4, - "start_angle": 0, "fill_opacity": 1, "stroke_width": 0, } - def __init__(self, outer_radius=2.0, inner_radius=1.0, color=WHITE, **kwargs): - Arc.__init__(self, outer_radius=outer_radius, inner_radius=inner_radius, color=color, **kwargs) + def __init__( + self, + angle=TAU / 4, + start_angle=0, + outer_radius=2.0, + inner_radius=1.0, + color=WHITE, + **kwargs + ): + self.inner_radius = inner_radius + self.outer_radius = outer_radius + Arc.__init__(self, angle=angle, start_angle=start_angle, color=color, **kwargs) def generate_points(self): inner_arc, outer_arc = [ @@ -532,9 +546,10 @@ def generate_points(self): class Line(TipableVMobject): - CONFIG = {"buff": 0, "path_arc": None} # angle of arc specified here - def __init__(self, start=LEFT, end=RIGHT, **kwargs): + def __init__(self, start=LEFT, end=RIGHT, path_arc=None, buff=0, **kwargs): + self.path_arc = path_arc + self.buff = buff digest_config(self, kwargs) self.set_start_and_end_attrs(start, end) VMobject.__init__(self, **kwargs) @@ -626,14 +641,18 @@ def set_opacity(self, opacity, family=True): class DashedLine(Line): - CONFIG = { - "dash_length": DEFAULT_DASH_LENGTH, - "dash_spacing": None, - "positive_space_ratio": 0.5, - } - def __init__(self, *args, **kwargs): - Line.__init__(self, *args, **kwargs) + def __init__( + self, + dash_length=DEFAULT_DASH_LENGTH, + dash_spacing=None, + positive_space_ratio=0.5, + **kwargs + ): + self.dash_length = dash_length + self.dash_spacing = dash_spacing + self.positive_space_ratio = positive_space_ratio + Line.__init__(self, **kwargs) ps_ratio = self.positive_space_ratio num_dashes = self.calculate_num_dashes(ps_ratio) dashes = DashedVMobject( @@ -672,9 +691,10 @@ def get_last_handle(self): class TangentLine(Line): - CONFIG = {"length": 1, "d_alpha": 1e-6} - def __init__(self, vmob, alpha, **kwargs): + def __init__(self, vmob, alpha, length=1, d_alpha=1e-6, **kwargs): + self.length = length + self.d_alpha = d_alpha digest_config(self, kwargs) da = self.d_alpha a1 = np.clip(alpha - da, 0, 1) @@ -686,9 +706,10 @@ def __init__(self, vmob, alpha, **kwargs): class Elbow(VMobject): - CONFIG = {"width": 0.2, "angle": 0} - def __init__(self, **kwargs): + def __init__(self, width=0.2, angle=0, **kwargs): + self.width = width + self.angle = angle VMobject.__init__(self, **kwargs) self.set_points_as_corners([UP, UP + RIGHT, RIGHT]) self.set_width(self.width, about_point=ORIGIN) @@ -696,16 +717,19 @@ def __init__(self, **kwargs): class Arrow(Line): - CONFIG = { - "stroke_width": 6, - "buff": MED_SMALL_BUFF, - "max_tip_length_to_length_ratio": 0.25, - "max_stroke_width_to_length_ratio": 5, - "preserve_tip_size_when_scaling": True, - } - def __init__(self, *args, **kwargs): - Line.__init__(self, *args, **kwargs) + def __init__( + self, + stroke_width=6, + buff=MED_SMALL_BUFF, + preserve_tip_size_when_scaling=True, + max_stroke_width_to_length_ratio=5, + max_tip_length_to_length_ratio=0.25, + **kwargs): + self.preserve_tip_size_when_scaling = preserve_tip_size_when_scaling + self.max_stroke_width_to_length_ratio = max_stroke_width_to_length_ratio + self.max_tip_length_to_length_ratio = max_tip_length_to_length_ratio + Line.__init__(self, stroke_width=stroke_width, buff=buff, **kwargs) # TODO, should this be affected when # Arrow.set_stroke is called? self.initial_stroke_width = self.stroke_width @@ -782,19 +806,18 @@ def set_stroke_width_from_length(self): class Vector(Arrow): - def __init__(self, direction=RIGHT, buff=0, **kwargs): self.buff = buff if len(direction) == 2: direction = np.append(np.array(direction), 0) - Arrow.__init__(self, ORIGIN, direction, buff=buff, **kwargs) + Arrow.__init__(self, start=ORIGIN, end=direction, buff=buff, **kwargs) class DoubleArrow(Arrow): - def __init__(self, *args, **kwargs): + def __init__(self, **kwargs): if "tip_shape_end" in kwargs: kwargs["tip_shape"] = kwargs.pop("tip_shape_end") - Arrow.__init__(self, *args, **kwargs) + Arrow.__init__(self, **kwargs) self.add_tip( at_start=True, tip_shape=kwargs.get("tip_shape_start", ArrowTriangleFilledTip), @@ -808,7 +831,6 @@ def __init__(self, points, **kwargs): class Polygon(VMobject): - def __init__(self, *vertices, color=BLUE, **kwargs): VMobject.__init__(self, color=color, **kwargs) self.set_points_as_corners([*vertices, vertices[0]]) @@ -852,7 +874,6 @@ def round_corners(self, radius=0.5): class RegularPolygon(Polygon): - def __init__(self, n=6, start_angle=None, **kwargs): self.start_angle = start_angle digest_config(self, kwargs, locals()) @@ -872,7 +893,6 @@ def __init__(self, **kwargs): class Rectangle(Polygon): - def __init__(self, height=2.0, width=4.0, color=WHITE, **kwargs): Polygon.__init__( self, UL, UR, DR, DL, height=height, width=width, color=color, **kwargs @@ -882,7 +902,6 @@ def __init__(self, height=2.0, width=4.0, color=WHITE, **kwargs): class Square(Rectangle): - def __init__(self, side_length=2.0, **kwargs): self.side_length = side_length Rectangle.__init__( @@ -891,7 +910,6 @@ def __init__(self, side_length=2.0, **kwargs): class RoundedRectangle(Rectangle): - def __init__(self, corner_radius=0.5, **kwargs): Rectangle.__init__(self, corner_radius=corner_radius, **kwargs) self.round_corners(corner_radius) diff --git a/tests/control_data/graphical_units_data/geometry/ArrowTest.npz b/tests/control_data/graphical_units_data/geometry/ArrowTest.npz new file mode 100644 index 0000000000000000000000000000000000000000..82f4f26c02bb5f2391dccdbdf1022498837afab6 GIT binary patch literal 2239 zcmWIWW@Zs#U|`??Vnv4kGh=7!0+|i0k_>zdA`EFoiMgrqDTyVCdU*wvj0^%`8K6=I zkSY*(d-rUXaH2@V!zEmXTuMz{myYh3u)-z4W8to1uB4WZgiQsZt9o|`XlIr#&fCkF ze@OeJR`$Y2Q$-SUxDH-;mR=XsrgFY9-H@3%{rks52A>~SuKxHabmNDeAC_*qd$0EL zN*gY%czfFwAass9hVz zn^nH*;C6+dbM!^H1R*XQB}YSmxDdEGH&)Z_>($pg-!n2W803d_9bHjbZ2If#rITJ+AExUi$8s*^2=Gk)^{ZTS4=!2^X?WxE3xUp!GO4h;Ls zEALkwe4!0wJ!#wR6%TZ@iutP5Uql%g9BL--0t@(vF9!=8sPKdc%$c$bETFSIXr;*4 zD%-x3mqLGWF)&Q?-WhZ54u7}B<`)n%BXV|SeR%^!{gJ1_qNb&;no)dY}Smqd(9IJ|HIm1srM)$1YtCboQjz5&W?an;gu@$vxrhO+@e$z7$_5f;1VS4ioeOS&000vk BIMx6F literal 0 HcmV?d00001 diff --git a/tests/control_data/graphical_units_data/geometry/CustomDashedLineTest.npz b/tests/control_data/graphical_units_data/geometry/CustomDashedLineTest.npz new file mode 100644 index 0000000000000000000000000000000000000000..32560eb924656e5b03153265f227cf4ce989bfc9 GIT binary patch literal 2255 zcmWIWW@Zs#U|`??Vnv3E3trr|KxPB0Bm*CV2t!&?Vs2`DN@7W(US2^ZBZB}~2B?$) zqzVMyUN`I#PLw(J@I=|=rQAzA#hIA{)eb#kd?O;wt<9My#$Biy7`&pkYW-C0CtN!Z z?YQs2w_(pwi`SnIGXJ0XD!0D=-k$2e-~LX%*njc-&$DUY3$5!dXaE28uO{yNv+d=# z^KXBh&R>3ew(rmXS$`|H@BF|2_m+RVcK)y1wW}`d{JQuxuWn`qp07JE_ixq3j4MnK zH;s}59|8xQV`5{sKK{5P_}#wmKa;?+RXXcrd)gTf$VZjRBr z{rTq|&GP%z109GB$J32wZu$Lp-w+EzY zTDEsj(f7UV3=9bwC87)r4sPL$3=AoQjJayntEyER1DysR#D|22-Zt@Fey8?5Fpwl> zT?(Ea4$aQJ>wtyri5FVHKoaAhZF}wcrK`03@|ZQvd(} literal 0 HcmV?d00001 diff --git a/tests/control_data/graphical_units_data/geometry/DashedLineTest.npz b/tests/control_data/graphical_units_data/geometry/DashedLineTest.npz new file mode 100644 index 0000000000000000000000000000000000000000..ea58c016ff0ca73bb82483b6b763bc76251ec20b GIT binary patch literal 2246 zcmWIWW@Zs#U|`??Vnv2|*M5hY0GSP}k_>zdA`EFoiMgrqDTyVCdU*wvj0^%`8K6=I zkSY*(d&}A*I#HtG;fji*++AH=(>1adxqJ+pkfWD3O;7Yy&=z0Kprngt-q8oI`f}y1 zE8Nrp(62ZF;QBYzrLTmQcN-)EFd+%MkBve~bVNsQvoBPE_Ex2s?%$YN1 zgocE;$ji(3$Hm9X*JfmBRApypf0;LL-iy0;?_Rup>((NEK0denjEoLDGqZ2e?}6pg zkMCX99xw0QyEpCZx^?T4!tTuU`upUG%CAR{lD_QSyZ6P<8oOV=epP+>`}gk)Zf@?2 z{{H@p#mnbi+PQC^-tNn1&-$LJyX$%G+_^>Rn{U2gXJ@~7{o1uf;#{pScJJPOar(4r zi-68?*MB!@X>ny`WZClHzkkmVEk6{rf5(oFxI2N~e_y=N`1R>i(U-Y%=e_{??_zjZ z*dlp3IXC@xK1+-1>g4vWTc`I6==%Eq#~2tMtlS)ab2YH^-2d3#;Xfl2EWAhQ(GVC7 s0Z0hgu-Y>Ocr!AIFym@mw?+L08Q64-v9sr literal 0 HcmV?d00001 diff --git a/tests/control_data/graphical_units_data/geometry/SmallDotTest.npz b/tests/control_data/graphical_units_data/geometry/SmallDotTest.npz new file mode 100644 index 0000000000000000000000000000000000000000..182b8bc2a8ee8c868441a9c2f782cd2789d5ba0e GIT binary patch literal 2033 zcmWIWW@Zs#U|`??Vnqg_JzE~evokO>uu3xUF^Djv6(#1T#-}8fB_C|CG;sA*r+LqdKgN{E0ZR^}PTMT2xot;%)P(PHF)%z} zd?b5y|K-pJ0)sXL p8vdV+5AbGW5@E(wK_i^rzzAZaR@VXEtZX1rMj*5S((}PpHUOm+xmf@J literal 0 HcmV?d00001 diff --git a/tests/test_graphical_units/test_geometry.py b/tests/test_graphical_units/test_geometry.py index 86720b603a..545e0b47ca 100644 --- a/tests/test_graphical_units/test_geometry.py +++ b/tests/test_graphical_units/test_geometry.py @@ -13,7 +13,7 @@ def construct(self): class ArcTest(Scene): def construct(self): - a = Arc(PI) + a = Arc(start_angle=PI) self.play(Animation(a)) @@ -23,6 +23,14 @@ def construct(self): self.play(Animation(a)) +class ArrowTest(Scene): + def construct(self): + a = Arrow() + self.play(Animation(a)) + b = Arrow(color=RED, stroke_width=12, end=2*LEFT, start=2*RIGHT).scale(2).shift(UP) + self.play(Animation(b)) + + class CurvedArrowTest(Scene): def construct(self): a = CurvedArrow(np.array([1, 1, 0]), np.array([2, 2, 0])) @@ -34,8 +42,8 @@ def construct(self): from manim.mobject.geometry import ArrowCircleTip, ArrowSquareFilledTip a = DoubleArrow( - np.array([-1, -1, 0]), - np.array([1, 1, 0]), + start=np.array([-1, -1, 0]), + end=np.array([1, 1, 0]), tip_shape_start=ArrowCircleTip, tip_shape_end=ArrowSquareFilledTip, ) @@ -48,6 +56,14 @@ def construct(self): self.play(Animation(circle)) +class SmallDotTest(Scene): + def construct(self): + a = SmallDot() + self.play(Animation(a)) + b = SmallDot(color=BLUE).shift(UP) + self.play(Animation(b)) + + class DotTest(Scene): def construct(self): dot = Dot() @@ -90,6 +106,32 @@ def construct(self): self.play(Animation(a)) +class DashedLineTest(Scene): + def construct(self): + a = DashedLine() + self.play(Animation(a)) + + +class CustomDashedLineTest(Scene): + def construct(self): + a = DashedLine(end=2*DOWN, start=2*UP, dash_length=0.5) + self.play(Animation(a)) + + +class TangentLineTest(Scene): + def construct(self): + circle = Circle(color=WHITE) + self.add(circle) + t1 = TangentLine(circle, 0.5, color=BLUE) + self.play(Animation(t1)) + t2 = TangentLine(circle, 1.0, length=2, color=RED) + self.play(Animation(t2)) + t3 = TangentLine(circle, 0.75, length=5, d_alpha=0.1, color=YELLOW) + self.play(Animation(t3)) + t4 = TangentLine(circle, 0.321, length=1.5, d_alpha=-0.1, color=GREEN) + self.play(Animation(t4)) + + class Elbowtest(Scene): def construct(self): a = Elbow() From 9eb3f196a6afa6e8e50bd2f2a4aa42ab2c51edf0 Mon Sep 17 00:00:00 2001 From: leotrs Date: Fri, 30 Oct 2020 23:18:11 -0400 Subject: [PATCH 6/7] add missing control file and run black --- manim/mobject/geometry.py | 53 +++++++++--------- .../geometry/TangentLineTest.npz | Bin 0 -> 7280 bytes tests/test_graphical_units/test_geometry.py | 8 ++- 3 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 tests/control_data/graphical_units_data/geometry/TangentLineTest.npz diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index e94fb0f77e..6f9d62fed8 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -233,20 +233,27 @@ class Arc(TipableVMobject): """A circular arc.""" def __init__( - self, - num_components=9, - arc_center=ORIGIN, - start_angle=0, - angle=TAU/4, - radius=1.0, - **kwargs): + self, + num_components=9, + arc_center=ORIGIN, + start_angle=0, + angle=TAU / 4, + radius=1.0, + **kwargs + ): self.num_components = num_components self.arc_center = arc_center self.radius = radius self.start_angle = start_angle self.angle = angle self._failed_to_get_center = False - VMobject.__init__(self, num_components=num_components, arc_center=arc_center, radius=radius, **kwargs) + VMobject.__init__( + self, + num_components=num_components, + arc_center=arc_center, + radius=radius, + **kwargs + ) def generate_points(self): self.set_pre_positioned_points() @@ -546,7 +553,6 @@ def generate_points(self): class Line(TipableVMobject): - def __init__(self, start=LEFT, end=RIGHT, path_arc=None, buff=0, **kwargs): self.path_arc = path_arc self.buff = buff @@ -641,13 +647,12 @@ def set_opacity(self, opacity, family=True): class DashedLine(Line): - def __init__( - self, - dash_length=DEFAULT_DASH_LENGTH, - dash_spacing=None, - positive_space_ratio=0.5, - **kwargs + self, + dash_length=DEFAULT_DASH_LENGTH, + dash_spacing=None, + positive_space_ratio=0.5, + **kwargs ): self.dash_length = dash_length self.dash_spacing = dash_spacing @@ -691,7 +696,6 @@ def get_last_handle(self): class TangentLine(Line): - def __init__(self, vmob, alpha, length=1, d_alpha=1e-6, **kwargs): self.length = length self.d_alpha = d_alpha @@ -706,7 +710,6 @@ def __init__(self, vmob, alpha, length=1, d_alpha=1e-6, **kwargs): class Elbow(VMobject): - def __init__(self, width=0.2, angle=0, **kwargs): self.width = width self.angle = angle @@ -717,15 +720,15 @@ def __init__(self, width=0.2, angle=0, **kwargs): class Arrow(Line): - def __init__( - self, - stroke_width=6, - buff=MED_SMALL_BUFF, - preserve_tip_size_when_scaling=True, - max_stroke_width_to_length_ratio=5, - max_tip_length_to_length_ratio=0.25, - **kwargs): + self, + stroke_width=6, + buff=MED_SMALL_BUFF, + preserve_tip_size_when_scaling=True, + max_stroke_width_to_length_ratio=5, + max_tip_length_to_length_ratio=0.25, + **kwargs + ): self.preserve_tip_size_when_scaling = preserve_tip_size_when_scaling self.max_stroke_width_to_length_ratio = max_stroke_width_to_length_ratio self.max_tip_length_to_length_ratio = max_tip_length_to_length_ratio diff --git a/tests/control_data/graphical_units_data/geometry/TangentLineTest.npz b/tests/control_data/graphical_units_data/geometry/TangentLineTest.npz new file mode 100644 index 0000000000000000000000000000000000000000..bb18236163b08e920dc64e0d432bb23fc6a3a9fb GIT binary patch literal 7280 zcmeHMX;f2Zw~qC*wo*{bq%zeiATlWs=72+mB0``T5W!GHKxCc?L(nSFqJV;cj1dPw zh6H31NQfl@WeUg?Aq+Alj0q4zAOpGQ#M?Wpb?=|M?$3smuyW4HKJR|^v!A{9d+eZn=lKYXtV(*1nc)J1U%l_T+nxXV$$7g&Qqt#N=q!KJbS$OaW$o)nkv}?pJXQLv;wy{Zrb%e> zcL%<`{7T>XVV|m=7>q}e z-XES)LXjR91q&nhBX#dA$nq@3m7*s4wRhvAI)g34%@^LqpISuQSy34KCqnwS0%I7} z9g2ItIQ7rxKM4Ha5%?sKV%#{CTX#Dbr2trA_aZgLNNRhnTc6SQC+ed6)mhQN;iZRh z$s7sqG($7~cI17MIWgLECd>K$g+W-}EhLa!=dgM{11F`Vr4wumj1w3W%}E0T13}}# z9SJAWOm)H-<3>9gXm6K}Q+Fso=CdyqHnH1|`xJ6J)k&?Mkp+jx6zbh*6d!XsY2xzdX0?dhOlgi}JO zmYJ^WuC{j)HQrpW*P(%6s<){S8ghH0$dg79*c_XmPk2$h?~nE!R1Re?1Tv(sZZvpz z&)(J#e@K$jm96jO7u;#mbm7@Y(F9g*bEVThg-x@=<*m=uoRTD49O5TSjQub)_rd48 ze@IfJv0pxp;b^?D^&-xMvudmZ{ zee>$IX0%OoVVW8D)Ri0^j_me1k z!L1%75iPht!QQxd{`{X3`QB+kQOs2LPcP|+P6q?H5Pga_eRR6jnwJzj+nx|P6=z`N z&Gw(~%5>*%uUl0*H#mofNJAhih1cuuNVlgd$jN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ccIq@4XIBkl z_2`aBVDEjhkY08`^w=M!hIpr`gA5ncQjjqTvdF08z27LIx7`r;hPA;r)yC+6Ht=AsQSl_hHJ_I7cZDv)#G3dSqzZ3LBbfO(ZK`K-qN{a3u$~wlP8@ zef-w-n*4kw+v!+>CR19KM!5cXhiwqH9_Tm{Z?Fe)``s~v0C`3Wk5PqU(d?>w^9;0~ zW@ULHsn~($NaorWHL!%DM4iDlGcJ#*IMFxJ(m*veRaRDZ-&z?(yltE7%(xgF989a5 z@7m=tm5Q(Aq+_k58yY5~)qNhiVqCy(CQ%I#y6=vh`2oz!-lNMSm0|#$=WKD5tJz^I zpU#@{*GSVfeP-4;7OV~(!3Xb-KmwYA5W zuLA5HiFtZ@P6ImuIGsst3w9fn<6$y4=%}3BWab|&{u0Al681+>}OymCjGWg>;l_=ap1N4 z%!fawUp&<6x`lmM?@v{sr$S@->m6=yv`6H9(b7PmElXr9T2o&D{gR{HalIjDli3 ze|>E_Nhtt2^+A(-uNqK_HDH_M0k{eJ=*Zb0U85IYPXn7Ea2k{ej4kQJRKuCy=ca<) z_!?+cG^fN|;Iq9N7%wNIjdb-iOIe~~b~j6Ip|@+u#^tstHWju2ypR@KU?xa6(wvFH z`_EU5jb&-N$N+%J07{lM_qGB@ECw~`dGSrM@y=WZX>FR6LBG0=Ld4Q)(E{! Date: Fri, 30 Oct 2020 23:30:19 -0400 Subject: [PATCH 7/7] fix doctest --- manim/mobject/geometry.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index 6f9d62fed8..910f78024f 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -750,7 +750,7 @@ def scale(self, factor, scale_tips=False, **kwargs): -------- :: - >>> arrow = Arrow(np.array([-1, -1, 0]), np.array([1, 1, 0]), buff=0) + >>> arrow = Arrow(start=np.array([-1, -1, 0]), end=np.array([1, 1, 0]), buff=0) >>> scaled_arrow = arrow.scale(2) >>> scaled_arrow.get_start_and_end() (array([-2., -2., 0.]), array([2., 2., 0.])) @@ -760,7 +760,7 @@ def scale(self, factor, scale_tips=False, **kwargs): Manually scaling the object using the default method :meth:`~.Mobject.scale` does not have the same properties:: - >>> new_arrow = Arrow(np.array([-1, -1, 0]), np.array([1, 1, 0]), buff=0) + >>> new_arrow = Arrow(start=np.array([-1, -1, 0]), end=np.array([1, 1, 0]), buff=0) >>> another_scaled_arrow = VMobject.scale(new_arrow, 2) >>> another_scaled_arrow.tip.tip_length == arrow.tip.tip_length False @@ -949,7 +949,7 @@ class ArrowTip(VMobject): ... RegularPolygon.__init__(self, n=5, **kwargs) ... self.set_width(self.length) ... self.set_height(self.length, stretch=True) - >>> arr = Arrow(np.array([-2, -2, 0]), np.array([2, 2, 0]), + >>> arr = Arrow(start=np.array([-2, -2, 0]), end=np.array([2, 2, 0]), ... tip_shape=MyCustomArrowTip) >>> isinstance(arr.tip, RegularPolygon) True @@ -961,7 +961,7 @@ class ArrowTip(VMobject): Using a class inherited from :class:`ArrowTip` to get a non-filled tip is a shorthand to manually specifying the arrow tip style as follows:: - >>> arrow = Arrow(np.array([0, 0, 0]), np.array([1, 1, 0]), + >>> arrow = Arrow(start=np.array([0, 0, 0]), end=np.array([1, 1, 0]), ... tip_style={'fill_opacity': 0, 'stroke_width': 3}) @@ -986,7 +986,7 @@ def base(self): -------- :: - >>> arrow = Arrow(np.array([0, 0, 0]), np.array([2, 0, 0]), buff=0) + >>> arrow = Arrow(start=np.array([0, 0, 0]), end=np.array([2, 0, 0]), buff=0) >>> arrow.tip.base.round(2) + 0. # add 0. to avoid negative 0 in output array([1.65, 0. , 0. ]) @@ -1001,7 +1001,7 @@ def tip_point(self): -------- :: - >>> arrow = Arrow(np.array([0, 0, 0]), np.array([2, 0, 0]), buff=0) + >>> arrow = Arrow(start=np.array([0, 0, 0]), end=np.array([2, 0, 0]), buff=0) >>> arrow.tip.tip_point.round(2) + 0. array([2., 0., 0.]) @@ -1016,7 +1016,7 @@ def vector(self): -------- :: - >>> arrow = Arrow(np.array([0, 0, 0]), np.array([2, 2, 0]), buff=0) + >>> arrow = Arrow(start=np.array([0, 0, 0]), end=np.array([2, 2, 0]), buff=0) >>> arrow.tip.vector.round(2) + 0. array([0.25, 0.25, 0. ]) @@ -1031,7 +1031,7 @@ def tip_angle(self): -------- :: - >>> arrow = Arrow(np.array([0, 0, 0]), np.array([1, 1, 0]), buff=0) + >>> arrow = Arrow(start=np.array([0, 0, 0]), end=np.array([1, 1, 0]), buff=0) >>> round(arrow.tip.tip_angle, 5) == round(PI/4, 5) True @@ -1046,7 +1046,7 @@ def tip_length(self): -------- :: - >>> arrow = Arrow(np.array([0, 0, 0]), np.array([1, 2, 0])) + >>> arrow = Arrow(start=np.array([0, 0, 0]), end=np.array([1, 2, 0])) >>> round(arrow.tip.tip_length, 3) 0.35