diff --git a/manimlib/animation/transform_matching_parts.py b/manimlib/animation/transform_matching_parts.py index 51e69e6c..c37c16c3 100644 --- a/manimlib/animation/transform_matching_parts.py +++ b/manimlib/animation/transform_matching_parts.py @@ -83,19 +83,22 @@ class TransformMatchingParts(AnimationGroup): new_source_pieces = source.family_members_with_points() new_target_pieces = target.family_members_with_points() if len(new_source_pieces) == 0 or len(new_target_pieces) == 0: - # Don't animate null sorces + # Don't animate null sorces or null targets return source_is_new = all(char in self.source_pieces for char in new_source_pieces) target_is_new = all(char in self.target_pieces for char in new_target_pieces) - if source_is_new and target_is_new: - transform_type = self.mismatch_animation - if source.has_same_shape_as(target): - transform_type = self.match_animation - self.anims.append(transform_type(source, target, **self.anim_config)) - for char in new_source_pieces: - self.source_pieces.remove(char) - for char in new_target_pieces: - self.target_pieces.remove(char) + if not source_is_new or not target_is_new: + return + + transform_type = self.mismatch_animation + if source.has_same_shape_as(target): + transform_type = self.match_animation + + self.anims.append(transform_type(source, target, **self.anim_config)) + for char in new_source_pieces: + self.source_pieces.remove(char) + for char in new_target_pieces: + self.target_pieces.remove(char) def find_pairs_with_matching_shapes( self, @@ -136,8 +139,8 @@ class TransformMatchingStrings(TransformMatchingParts): for substr in [ *source.get_specified_substrings(), *target.get_specified_substrings(), - *source.get_string(), # TODO, have this return symbols, not characters - *target.get_string(), + *source.get_symbol_substrings(), + *target.get_symbol_substrings(), ] ] ]