A community-maintained Python framework for creating mathematical animations.
Made Mobject.copy somewhat lighter-weight
Grant Sanderson41b4483fd17c
diff --git a/mobject/mobject.py b/mobject/mobject.pyindex b8339659c..6305d15d9 100644--- a/mobject/mobject.py+++ b/mobject/mobject.py@@ -1,8 +1,8 @@import numpy as npimport operator as opimport os+import copyfrom PIL import Image-from copy import deepcopyfrom colour import Colorfrom helpers import *@@ -97,7 +97,15 @@ class Mobject(object):)def copy(self):- return deepcopy(self)+ copy_mobject = copy.copy(self)+ copy_mobject.points = np.array(self.points)+ copy_mobject.submobjects = [+ submob.copy() for submob in self.submobjects+ ]+ return copy_mobject++ def deepcopy(self):+ return copy.deepcopy(self)def generate_target(self):self.target = None #Prevent exponential explosiondiff --git a/mobject/vectorized_mobject.py b/mobject/vectorized_mobject.pyindex 27a6452c9..c6fb8be67 100644--- a/mobject/vectorized_mobject.py+++ b/mobject/vectorized_mobject.py@@ -200,9 +200,7 @@ class VMobject(Mobject):but will be tracked in a separate special list for whenit comes time to display."""- subpath_mobject = self.copy()#TODO, better way?- subpath_mobject.submobjects = []- # subpath_mobject = self.__class__()+ subpath_mobject = VMobject()subpath_mobject.is_subpath = Truesubpath_mobject.set_points(points)self.add(subpath_mobject)