@@ -58,6 +58,10 @@ class Mobject(Container):
58
58
points : :class:`numpy.ndarray`
59
59
The points of the objects.
60
60
61
+ .. seealso::
62
+
63
+ :class:`~.VMobject`
64
+
61
65
"""
62
66
63
67
def __init__ (self , color = WHITE , name = None , dim = 3 , target = None , z_index = 0 , ** kwargs ):
@@ -1755,9 +1759,11 @@ def get_critical_point(self, direction):
1755
1759
# Pseudonyms for more general get_critical_point method
1756
1760
1757
1761
def get_edge_center (self , direction ) -> np .ndarray :
1762
+ """Get edge coordinates for certain direction."""
1758
1763
return self .get_critical_point (direction )
1759
1764
1760
1765
def get_corner (self , direction ) -> np .ndarray :
1766
+ """Get corner coordinates for certain direction."""
1761
1767
return self .get_critical_point (direction )
1762
1768
1763
1769
def get_center (self ) -> np .ndarray :
@@ -1788,10 +1794,12 @@ def get_left(self) -> np.ndarray:
1788
1794
"""Get left coordinates of a box bounding the :class:`~.Mobject`"""
1789
1795
return self .get_edge_center (LEFT )
1790
1796
1791
- def get_zenith (self ):
1797
+ def get_zenith (self ) -> np .ndarray :
1798
+ """Get zenith coordinates of a box bounding a 3D :class:`~.Mobject`."""
1792
1799
return self .get_edge_center (OUT )
1793
1800
1794
- def get_nadir (self ):
1801
+ def get_nadir (self ) -> np .ndarray :
1802
+ """Get nadir (opposite the zenith) coordinates of a box bounding a 3D :class:`~.Mobject`."""
1795
1803
return self .get_edge_center (IN )
1796
1804
1797
1805
def length_over_dim (self , dim ):
@@ -1855,31 +1863,38 @@ def get_z_index_reference_point(self):
1855
1863
z_index_group = getattr (self , "z_index_group" , self )
1856
1864
return z_index_group .get_center ()
1857
1865
1858
- def has_points (self ):
1866
+ def has_points (self ) -> bool :
1859
1867
"""Check if :class:`~.Mobject` contains points. """
1860
1868
return len (self .points ) > 0
1861
1869
1862
- def has_no_points (self ):
1870
+ def has_no_points (self ) -> bool :
1871
+ """Check if :class:`~.Mobject` *does not* contains points."""
1863
1872
return not self .has_points ()
1864
1873
1865
1874
# Match other mobject properties
1866
1875
1867
1876
def match_color (self , mobject : "Mobject" ):
1877
+ """Match the color with the color of another :class:`~.Mobject`."""
1868
1878
return self .set_color (mobject .get_color ())
1869
1879
1870
1880
def match_dim_size (self , mobject : "Mobject" , dim , ** kwargs ):
1881
+ """Match the specified dimension with the dimension of another :class:`~.Mobject`."""
1871
1882
return self .rescale_to_fit (mobject .length_over_dim (dim ), dim , ** kwargs )
1872
1883
1873
1884
def match_width (self , mobject : "Mobject" , ** kwargs ):
1885
+ """Match the width with the width of another :class:`~.Mobject`."""
1874
1886
return self .match_dim_size (mobject , 0 , ** kwargs )
1875
1887
1876
1888
def match_height (self , mobject : "Mobject" , ** kwargs ):
1889
+ """Match the height with the height of another :class:`~.Mobject`."""
1877
1890
return self .match_dim_size (mobject , 1 , ** kwargs )
1878
1891
1879
1892
def match_depth (self , mobject : "Mobject" , ** kwargs ):
1893
+ """Match the depth with the depth of another :class:`~.Mobject`."""
1880
1894
return self .match_dim_size (mobject , 2 , ** kwargs )
1881
1895
1882
1896
def match_coord (self , mobject : "Mobject" , dim , direction = ORIGIN ):
1897
+ """Match the coordinates with the coordinates of another :class:`~.Mobject`."""
1883
1898
return self .set_coord (
1884
1899
mobject .get_coord (dim , direction ),
1885
1900
dim = dim ,
@@ -1890,7 +1905,7 @@ def match_x(self, mobject: "Mobject", direction=ORIGIN):
1890
1905
"""Match x coord. to the x coord. of another :class:`~.Mobject`."""
1891
1906
return self .match_coord (mobject , 0 , direction )
1892
1907
1893
- def Match_y (self , mobject : "Mobject" , direction = ORIGIN ):
1908
+ def match_y (self , mobject : "Mobject" , direction = ORIGIN ):
1894
1909
"""Match y coord. to the x coord. of another :class:`~.Mobject`."""
1895
1910
return self .match_coord (mobject , 1 , direction )
1896
1911
@@ -1904,7 +1919,9 @@ def align_to(
1904
1919
direction = ORIGIN ,
1905
1920
alignment_vect = UP ,
1906
1921
):
1907
- """Examples:
1922
+ """Aligns mobject to another :class:`~.Mobject` in a certain direction.
1923
+
1924
+ Examples:
1908
1925
mob1.align_to(mob2, UP) moves mob1 vertically so that its
1909
1926
top edge lines ups with mob2's top edge.
1910
1927
@@ -1989,6 +2006,21 @@ def construct(self):
1989
2006
return self
1990
2007
1991
2008
def arrange_in_grid (self , n_rows = None , n_cols = None , ** kwargs ):
2009
+ """Sorts :class:`~.Mobject` next to each other on screen using a grid.
2010
+
2011
+ Examples
2012
+ --------
2013
+
2014
+ .. manim:: ArrangeExample
2015
+ :save_last_frame:
2016
+
2017
+ class ArrangeExample(Scene):
2018
+ def construct(self):
2019
+ self.add(*[Square(color= random_bright_color()) for i in range(0,5)])
2020
+ x = VGroup(*self.mobjects).arrange_in_grid(buff=0.2)
2021
+ self.add(x)
2022
+ """
2023
+
1992
2024
submobs = self .submobjects
1993
2025
if n_rows is None and n_cols is None :
1994
2026
n_cols = int (np .sqrt (len (submobs )))
@@ -2010,12 +2042,14 @@ def arrange_in_grid(self, n_rows=None, n_cols=None, **kwargs):
2010
2042
return self
2011
2043
2012
2044
def sort (self , point_to_num_func = lambda p : p [0 ], submob_func = None ):
2045
+ """Sorts the list of :attr:`submobjects` by a function defined by ``submob_func``."""
2013
2046
if submob_func is None :
2014
2047
submob_func = lambda m : point_to_num_func (m .get_center ())
2015
2048
self .submobjects .sort (key = submob_func )
2016
2049
return self
2017
2050
2018
2051
def shuffle (self , recursive = False ):
2052
+ """Shuffles the list of :attr:`submobjects`."""
2019
2053
if recursive :
2020
2054
for submob in self .submobjects :
2021
2055
submob .shuffle (recursive = True )
0 commit comments