From 8e6265d35e22d84f8fb5002308e206f2c1bf67a1 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 3 Nov 2022 16:17:17 -0700 Subject: [PATCH 1/5] Give set_color_by_gradient more expected behavior https://github.com/3b1b/manim/issues/1882 --- manimlib/mobject/mobject.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index bab9323f..872f85db 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -1265,7 +1265,10 @@ class Mobject(object): return self.data["rgbas"][0, 3] def set_color_by_gradient(self, *colors: ManimColor): - self.set_submobject_colors_by_gradient(*colors) + if self.has_points(): + self.set_color(colors) + else: + self.set_submobject_colors_by_gradient(*colors) return self def set_submobject_colors_by_gradient(self, *colors: ManimColor): From f8785378141d2765b946f5ed160cb43eea85a272 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 3 Nov 2022 16:31:19 -0700 Subject: [PATCH 2/5] Don't have Matrix try to convert lists of Mobject into numpy arrays https://github.com/3b1b/manim/issues/1878 --- manimlib/mobject/matrix.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/manimlib/mobject/matrix.py b/manimlib/mobject/matrix.py index 76688a4d..bb4aad84 100644 --- a/manimlib/mobject/matrix.py +++ b/manimlib/mobject/matrix.py @@ -94,15 +94,12 @@ class Matrix(VMobject): or mobjects """ VMobject.__init__(self, **kwargs) - matrix = self.matrix = np.array(matrix, ndmin=2) - mob_matrix = self.matrix_to_mob_matrix(matrix) + mob_matrix = self.mob_matrix = self.matrix_to_mob_matrix(matrix) self.organize_mob_matrix(mob_matrix) - # self.elements = VGroup(*mob_matrix.flatten()) self.elements = VGroup(*it.chain(*mob_matrix)) self.add(self.elements) self.add_brackets() self.center() - self.mob_matrix = mob_matrix if self.add_background_rectangles_to_entries: for mob in self.elements: mob.add_background_rectangle() @@ -129,7 +126,7 @@ class Matrix(VMobject): return self def add_brackets(self): - height = self.matrix.shape[0] + height = len(self.mob_matrix) bracket_pair = Tex("".join([ "\\left[", "\\begin{array}{c}", From 84fa3de435b5ea7651c156a0f707f565b356205e Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 3 Nov 2022 16:35:41 -0700 Subject: [PATCH 3/5] By default, don't let Mobject.become match updaters This causes the use of Mobject.become in an updater function to make the mobject immediately lose its updater. https://github.com/3b1b/manim/issues/1877 --- manimlib/mobject/mobject.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 872f85db..ef23bc49 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -627,7 +627,7 @@ class Mobject(object): mobject = pickle.load(fp) return mobject - def become(self, mobject: Mobject): + def become(self, mobject: Mobject, match_updaters=False): """ Edit all data and submobjects to be idential to another mobject @@ -647,7 +647,8 @@ class Mobject(object): if isinstance(value, Mobject) and value in family2: setattr(self, attr, family1[family2.index(value)]) self.refresh_bounding_box(recurse_down=True) - self.match_updaters(mobject) + if match_updaters: + self.match_updaters(mobject) return self def looks_identical(self, mobject: Mobject): From a2606c7e37dfb133ea644e90d6017ec34fbc2dd0 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 3 Nov 2022 16:48:14 -0700 Subject: [PATCH 4/5] Make sure find_intersection returns a result matching the shape of inputs --- manimlib/utils/space_ops.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manimlib/utils/space_ops.py b/manimlib/utils/space_ops.py index faeef158..7c2cfe4e 100644 --- a/manimlib/utils/space_ops.py +++ b/manimlib/utils/space_ops.py @@ -294,7 +294,10 @@ def find_intersection( denom[abs(denom) < threshold] = np.inf # So that ratio goes to 0 there ratio = numer / denom ratio = np.repeat(ratio, n).reshape((m, n)) - return p0 + ratio * v0 + result = p0 + ratio * v0 + if m == 1: + return result[0] + return result def get_closest_point_on_line( From 8adf99b8a710167eee4d95f65ea13b3c74c85faa Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 3 Nov 2022 16:48:30 -0700 Subject: [PATCH 5/5] Fix Circle.point_at_angle https://github.com/3b1b/manim/issues/1875 --- manimlib/mobject/geometry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manimlib/mobject/geometry.py b/manimlib/mobject/geometry.py index 768be338..abe3eec7 100644 --- a/manimlib/mobject/geometry.py +++ b/manimlib/mobject/geometry.py @@ -347,7 +347,7 @@ class Circle(Arc): def point_at_angle(self, angle: float) -> np.ndarray: start_angle = self.get_start_angle() return self.point_from_proportion( - (angle - start_angle) / TAU + ((angle - start_angle) % TAU) / TAU ) def get_radius(self) -> float: