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