Fixed bug with VMobject.close_new_points

This commit is contained in:
Grant Sanderson
2018-08-21 19:25:34 -07:00
parent 98a7f254ee
commit 8103b723a8
2 changed files with 10 additions and 6 deletions

View File

@@ -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

View File

@@ -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":