Some bug fixes associated with new copy method

This commit is contained in:
Grant Sanderson
2017-03-25 12:18:33 -07:00
parent ff0c122d4d
commit 6ab2d5f3b2
2 changed files with 15 additions and 1 deletions

View File

@ -128,6 +128,20 @@ class TexMobject(SVGMobject):
if test(tex, part_tex) if test(tex, part_tex)
] ]
def copy(self):
## TODO, is this the best way?
copy_mobject = SVGMobject.copy(self)
if hasattr(self, "expression_parts"):
pairs = zip(
self.submobject_family(),
copy_mobject.submobject_family()
)
for submob, copy_submob in pairs:
if submob in self.original_submobjects:
index = self.original_submobjects.index(submob)
copy_mobject.original_submobjects[index] = copy_submob
return copy_mobject
def get_part_by_tex(self, tex, **kwargs): def get_part_by_tex(self, tex, **kwargs):
all_parts = self.get_parts_by_tex(tex, **kwargs) all_parts = self.get_parts_by_tex(tex, **kwargs)
return all_parts[0] if all_parts else None return all_parts[0] if all_parts else None

View File

@ -200,7 +200,7 @@ class VMobject(Mobject):
but will be tracked in a separate special list for when but will be tracked in a separate special list for when
it comes time to display. it comes time to display.
""" """
subpath_mobject = VMobject() subpath_mobject = self.copy()##Really helps to be of the same class
subpath_mobject.is_subpath = True subpath_mobject.is_subpath = True
subpath_mobject.set_points(points) subpath_mobject.set_points(points)
self.add(subpath_mobject) self.add(subpath_mobject)