mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
In StringMobject.select_parts, default to using select_unisolated_substring if substring was not explicitly isolated
This commit is contained in:
parent
05f02f5154
commit
c7ba775845
1 changed files with 5 additions and 9 deletions
|
@ -36,7 +36,7 @@ class StringMobject(SVGMobject, ABC):
|
||||||
or a 2-tuple containing integers or None, or a collection of the above.
|
or a 2-tuple containing integers or None, or a collection of the above.
|
||||||
Note, substrings specified cannot *partly* overlap with each other.
|
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,
|
The additional one is generated with some color commands inserted,
|
||||||
so that each submobject of the original `SVGMobject` will be labelled
|
so that each submobject of the original `SVGMobject` will be labelled
|
||||||
by the color of its paired submobject from the additional `SVGMobject`.
|
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:
|
def select_parts(self, selector: Selector) -> VGroup:
|
||||||
indices_list = self.get_submob_indices_lists_by_selector(selector)
|
specified_substrings = self.get_specified_substrings()
|
||||||
if indices_list:
|
if isinstance(selector, str) and selector not in specified_substrings:
|
||||||
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")
|
|
||||||
return self.select_unisolated_substring(selector)
|
return self.select_unisolated_substring(selector)
|
||||||
else:
|
indices_list = self.get_submob_indices_lists_by_selector(selector)
|
||||||
return VGroup()
|
return self.build_parts_from_indices_lists(indices_list)
|
||||||
|
|
||||||
def __getitem__(self, value: int | slice | Selector) -> VMobject:
|
def __getitem__(self, value: int | slice | Selector) -> VMobject:
|
||||||
if isinstance(value, (int, slice)):
|
if isinstance(value, (int, slice)):
|
||||||
|
|
Loading…
Add table
Reference in a new issue