mirror of
https://github.com/3b1b/manim.git
synced 2025-08-02 19:46:21 +08:00
Add Mobject.get_ancestors
This commit is contained in:
@ -343,6 +343,14 @@ class Mobject(object):
|
||||
def family_members_with_points(self):
|
||||
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):
|
||||
if self in mobjects:
|
||||
raise Exception("Mobject cannot contain self")
|
||||
|
Reference in New Issue
Block a user