mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Add Mobject.get_ancestors
This commit is contained in:
parent
efe051b8e1
commit
db884b0a67
1 changed files with 8 additions and 0 deletions
|
@ -343,6 +343,14 @@ class Mobject(object):
|
||||||
def family_members_with_points(self):
|
def family_members_with_points(self):
|
||||||
return [m for m in self.get_family() if m.has_points()]
|
return [m for m in self.get_family() if m.has_points()]
|
||||||
|
|
||||||
|
def get_ancestors(self) -> list[Mobject]:
|
||||||
|
ancestors = list(self.parents)
|
||||||
|
n = 0
|
||||||
|
while n < len(ancestors):
|
||||||
|
ancestors.extend(ancestors[n].parents)
|
||||||
|
n += 1
|
||||||
|
return ancestors
|
||||||
|
|
||||||
def add(self, *mobjects: Mobject):
|
def add(self, *mobjects: Mobject):
|
||||||
if self in mobjects:
|
if self in mobjects:
|
||||||
raise Exception("Mobject cannot contain self")
|
raise Exception("Mobject cannot contain self")
|
||||||
|
|
Loading…
Add table
Reference in a new issue