Small adjustments to VMobject.insert_n_anchor_points

This commit is contained in:
Grant Sanderson 2018-01-28 16:27:07 -08:00
parent 1a44b0e52d
commit 32b46e078c
2 changed files with 13 additions and 1 deletions

View file

@ -353,7 +353,8 @@ class VMobject(Mobject):
for index in range(num_curves):
curr_bezier_points = self.points[3*index:3*index+4]
num_inter_curves = sum(index_allocation == index)
alphas = np.arange(0, num_inter_curves+1)/float(num_inter_curves)
alphas = np.linspace(0, 1, num_inter_curves+1)
# alphas = np.arange(0, num_inter_curves+1)/float(num_inter_curves)
for a, b in zip(alphas, alphas[1:]):
new_points = partial_bezier_points(
curr_bezier_points, a, b

View file

@ -333,6 +333,17 @@ class Line(VMobject):
self.shift(new_start - self.get_start())
return self
def insert_n_anchor_points(self, n):
if not self.path_arc:
n_anchors = self.get_num_anchor_points()
new_num_points = 3*(n_anchors + n)+1
self.points = np.array([
self.point_from_proportion(alpha)
for alpha in np.linspace(0, 1, new_num_points)
])
else:
VMobject.insert_n_anchor_points(self, n)
class DashedLine(Line):
CONFIG = {
"dashed_segment_length" : 0.05