Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed bug with VMobject.close_new_points

Grant Sanderson8103b723a83d
diff --git a/mobject/geometry.py b/mobject/geometry.py
index 132aea986..cdc6bc7a9 100644
--- a/mobject/geometry.py
+++ b/mobject/geometry.py
@@ -538,7 +538,7 @@ class Arrow(Line):
def set_rectangular_stem_points(self):
start, end = self.get_start_and_end()
- tip_base_points = self.tip[0].get_anchors()[1:]
+ tip_base_points = self.tip[0].get_anchors()[1:3]
tip_base = center_of_mass(tip_base_points)
tbp1, tbp2 = tip_base_points
perp_vect = tbp2 - tbp1
diff --git a/mobject/types/vectorized_mobject.py b/mobject/types/vectorized_mobject.py
index 39df19d8a..253193057 100644
--- a/mobject/types/vectorized_mobject.py
+++ b/mobject/types/vectorized_mobject.py
@@ -336,7 +336,7 @@ class VMobject(Mobject):
def set_points_as_corners(self, points):
if len(points) <= 1:
return self
- points = np.array(points)
+ points = self.prepare_new_anchor_points(points)
self.set_anchors_and_handles(points, *[
interpolate(points[:-1], points[1:], alpha)
for alpha in (1. / 3, 2. / 3)
@@ -346,19 +346,23 @@ class VMobject(Mobject):
def set_points_smoothly(self, points):
if len(points) <= 1:
return self
+ points = self.prepare_new_anchor_points(points)
h1, h2 = get_smooth_handle_points(points)
self.set_anchors_and_handles(points, h1, h2)
return self
+ def prepare_new_anchor_points(self, points):
+ if not isinstance(points, np.ndarray):
+ points = np.array(points)
+ if self.close_new_points and not is_closed(points):
+ points = np.append(points, [points[0]], axis=0)
+ return points
+
def set_points(self, points):
self.points = np.array(points)
return self
def set_anchor_points(self, points, mode="smooth"):
- if not isinstance(points, np.ndarray):
- points = np.array(points)
- if self.close_new_points and not is_closed(points):
- points = np.append(points, [points[0]], axis=0)
if mode == "smooth":
self.set_points_smoothly(points)
elif mode == "corners":