mirror of
https://github.com/3b1b/manim.git
synced 2025-08-02 19:46:21 +08:00
In StringMobject.select_parts, default to using select_unisolated_substring if substring was not explicitly isolated
This commit is contained in:
@ -36,7 +36,7 @@ class StringMobject(SVGMobject, ABC):
|
||||
or a 2-tuple containing integers or None, or a collection of the above.
|
||||
Note, substrings specified cannot *partly* overlap with each other.
|
||||
|
||||
Each instance of `StringMobject` generates 2 svg files.
|
||||
Each instance of `StringMobject` may generate 2 svg files.
|
||||
The additional one is generated with some color commands inserted,
|
||||
so that each submobject of the original `SVGMobject` will be labelled
|
||||
by the color of its paired submobject from the additional `SVGMobject`.
|
||||
@ -546,15 +546,11 @@ class StringMobject(SVGMobject, ABC):
|
||||
])
|
||||
|
||||
def select_parts(self, selector: Selector) -> VGroup:
|
||||
indices_list = self.get_submob_indices_lists_by_selector(selector)
|
||||
if indices_list:
|
||||
return self.build_parts_from_indices_lists(indices_list)
|
||||
elif isinstance(selector, str):
|
||||
# Otherwise, try finding substrings which weren't specifically isolated
|
||||
log.warning("Accessing unisolated substring, results may not be as expected")
|
||||
specified_substrings = self.get_specified_substrings()
|
||||
if isinstance(selector, str) and selector not in specified_substrings:
|
||||
return self.select_unisolated_substring(selector)
|
||||
else:
|
||||
return VGroup()
|
||||
indices_list = self.get_submob_indices_lists_by_selector(selector)
|
||||
return self.build_parts_from_indices_lists(indices_list)
|
||||
|
||||
def __getitem__(self, value: int | slice | Selector) -> VMobject:
|
||||
if isinstance(value, (int, slice)):
|
||||
|
Reference in New Issue
Block a user