mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Clean up TransformMatchingStrings
This commit is contained in:
parent
3aa9eb6372
commit
4c1f1f8749
1 changed files with 15 additions and 12 deletions
|
@ -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(),
|
||||
]
|
||||
]
|
||||
]
|
||||
|
|
Loading…
Add table
Reference in a new issue