Skip to content

Commit

Permalink
Add example to family_members_with_points method in Mobject
Browse files Browse the repository at this point in the history
  • Loading branch information
irvanalhaq9 committed Jan 21, 2025
1 parent 6ca08fd commit 6dd955e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,25 @@ def get_family(self, recurse: bool = True) -> list[Self]:
return remove_list_redundancies(all_mobjects)

def family_members_with_points(self) -> list[Self]:
"""Lists all mobjects that have points in the hierarchy (family) of the given mobject.
Returns
-------
list
A list of mobjects that have points in the family of the given mobject.
Examples
--------
::
>>> from manim import Square, Rectangle, VGroup, Group, Mobject, VMobject
>>> s, r, m, v = Square(), Rectangle(), Mobject(), VMobject()
>>> vg = VGroup(s, r)
>>> gr = Group(vg, m, v)
>>> gr.family_members_with_points()
[Square, Rectangle]
"""
return [m for m in self.get_family() if m.get_num_points() > 0]

def arrange(
Expand Down

0 comments on commit 6dd955e

Please sign in to comment.