From 6ab2d5f3b26e077764f77f860c80dad3530f52d6 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sat, 25 Mar 2017 12:18:33 -0700 Subject: [PATCH] Some bug fixes associated with new copy method --- mobject/tex_mobject.py | 14 ++++++++++++++ mobject/vectorized_mobject.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mobject/tex_mobject.py b/mobject/tex_mobject.py index 1aeb17d0..c31603eb 100644 --- a/mobject/tex_mobject.py +++ b/mobject/tex_mobject.py @@ -128,6 +128,20 @@ class TexMobject(SVGMobject): 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): all_parts = self.get_parts_by_tex(tex, **kwargs) return all_parts[0] if all_parts else None diff --git a/mobject/vectorized_mobject.py b/mobject/vectorized_mobject.py index c6fb8be6..288c1960 100644 --- a/mobject/vectorized_mobject.py +++ b/mobject/vectorized_mobject.py @@ -200,7 +200,7 @@ class VMobject(Mobject): but will be tracked in a separate special list for when 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.set_points(points) self.add(subpath_mobject)