@@ -1011,9 +1011,11 @@ def scale(self, scale_factor: float, **kwargs) -> "Mobject":
10111011 return self
10121012
10131013 def rotate_about_origin (self , angle , axis = OUT , axes = []):
1014+ """Rotates the :class:`~.Mobject` about the ORIGIN, which is at [0,0,0]."""
10141015 return self .rotate (angle , axis , about_point = ORIGIN )
10151016
10161017 def rotate (self , angle , axis = OUT , ** kwargs ):
1018+ """Rotates the :class:`~.Mobject` about a certain point."""
10171019 if config ["use_opengl_renderer" ]:
10181020 rot_matrix_T = rotation_matrix_transpose (angle , axis )
10191021 self .apply_points_function (
@@ -1028,6 +1030,22 @@ def rotate(self, angle, axis=OUT, **kwargs):
10281030 return self
10291031
10301032 def flip (self , axis = UP , ** kwargs ):
1033+ """Flips/Mirrors an mobject about its center.
1034+
1035+ Examples
1036+ --------
1037+
1038+ .. manim:: FlipExample
1039+ :save_last_frame:
1040+
1041+ class FlipExample(Scene):
1042+ def construct(self):
1043+ s= Line(LEFT, RIGHT+UP).shift(4*LEFT)
1044+ self.add(s)
1045+ s2= s.copy().flip()
1046+ self.add(s2)
1047+
1048+ """
10311049 return self .rotate (TAU / 2 , axis , ** kwargs )
10321050
10331051 def stretch (self , factor , dim , ** kwargs ):
@@ -1198,7 +1216,7 @@ def next_to(
11981216 index_of_submobject_to_align = None ,
11991217 coor_mask = np .array ([1 , 1 , 1 ]),
12001218 ):
1201- """Move this mobject next to another mobject or coordinate.
1219+ """Move this :class:`~.Mobject` next to another's :class:`~.Mobject` or coordinate.
12021220
12031221 Examples
12041222 --------
@@ -1277,7 +1295,7 @@ def rescale_to_fit(self, length, dim, stretch=False, **kwargs):
12771295 return self
12781296
12791297 def scale_to_fit_width (self , width , ** kwargs ):
1280- """Scales the mobject to fit a width while keeping height/depth proportional.
1298+ """Scales the :class:`~.Mobject` to fit a width while keeping height/depth proportional.
12811299
12821300 Returns
12831301 -------
@@ -1303,7 +1321,7 @@ def scale_to_fit_width(self, width, **kwargs):
13031321 return self .rescale_to_fit (width , 0 , stretch = False , ** kwargs )
13041322
13051323 def stretch_to_fit_width (self , width , ** kwargs ):
1306- """Stretches the mobject to fit a width, not keeping height/depth proportional.
1324+ """Stretches the :class:`~.Mobject` to fit a width, not keeping height/depth proportional.
13071325
13081326 Returns
13091327 -------
@@ -1329,7 +1347,7 @@ def stretch_to_fit_width(self, width, **kwargs):
13291347 return self .rescale_to_fit (width , 0 , stretch = True , ** kwargs )
13301348
13311349 def scale_to_fit_height (self , height , ** kwargs ):
1332- """Scales the mobject to fit a height while keeping width/depth proportional.
1350+ """Scales the :class:`~.Mobject` to fit a height while keeping width/depth proportional.
13331351
13341352 Returns
13351353 -------
@@ -1355,7 +1373,7 @@ def scale_to_fit_height(self, height, **kwargs):
13551373 return self .rescale_to_fit (height , 1 , stretch = False , ** kwargs )
13561374
13571375 def stretch_to_fit_height (self , height , ** kwargs ):
1358- """Stretches the mobject to fit a height, not keeping width/depth proportional.
1376+ """Stretches the :class:`~.Mobject` to fit a height, not keeping width/depth proportional.
13591377
13601378 Returns
13611379 -------
@@ -1381,12 +1399,12 @@ def stretch_to_fit_height(self, height, **kwargs):
13811399 return self .rescale_to_fit (height , 1 , stretch = True , ** kwargs )
13821400
13831401 def scale_to_fit_depth (self , depth , ** kwargs ):
1384- """Scales the mobject to fit a depth while keeping width/height proportional."""
1402+ """Scales the :class:`~.Mobject` to fit a depth while keeping width/height proportional."""
13851403
13861404 return self .rescale_to_fit (depth , 2 , stretch = False , ** kwargs )
13871405
13881406 def stretch_to_fit_depth (self , depth , ** kwargs ):
1389- """Stretches the mobject to fit a depth, not keeping width/height proportional."""
1407+ """Stretches the :class:`~.Mobject` to fit a depth, not keeping width/height proportional."""
13901408
13911409 return self .rescale_to_fit (depth , 2 , stretch = True , ** kwargs )
13921410
@@ -1398,12 +1416,15 @@ def set_coord(self, value, dim, direction=ORIGIN):
13981416 return self
13991417
14001418 def set_x (self , x , direction = ORIGIN ):
1419+ """Set x value of the center of the :class:`~.Mobject` (``int`` or ``float``)"""
14011420 return self .set_coord (x , 0 , direction )
14021421
14031422 def set_y (self , y , direction = ORIGIN ):
1423+ """Set y value of the center of the :class:`~.Mobject` (``int`` or ``float``)"""
14041424 return self .set_coord (y , 1 , direction )
14051425
14061426 def set_z (self , z , direction = ORIGIN ):
1427+ """Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)"""
14071428 return self .set_coord (z , 2 , direction )
14081429
14091430 def space_out_submobjects (self , factor = 1.5 , ** kwargs ):
@@ -1415,6 +1436,7 @@ def space_out_submobjects(self, factor=1.5, **kwargs):
14151436 def move_to (
14161437 self , point_or_mobject , aligned_edge = ORIGIN , coor_mask = np .array ([1 , 1 , 1 ])
14171438 ):
1439+ """Move center of the :class:`~.Mobject` to certain coordinate."""
14181440 if isinstance (point_or_mobject , Mobject ):
14191441 target = point_or_mobject .get_critical_point (aligned_edge )
14201442 else :
@@ -1437,7 +1459,9 @@ def replace(self, mobject, dim_to_match=0, stretch=False):
14371459 self .shift (mobject .get_center () - self .get_center ())
14381460 return self
14391461
1440- def surround (self , mobject , dim_to_match = 0 , stretch = False , buff = MED_SMALL_BUFF ):
1462+ def surround (
1463+ self , mobject : "Mobject" , dim_to_match = 0 , stretch = False , buff = MED_SMALL_BUFF
1464+ ):
14411465 self .replace (mobject , dim_to_match , stretch )
14421466 length = mobject .length_over_dim (dim_to_match )
14431467 self .scale_in_place ((length + buff ) / length )
@@ -1590,6 +1614,7 @@ def get_color(self):
15901614 ##
15911615
15921616 def save_state (self ):
1617+ """Save the current state (position, color & size). Can be restored with :meth:`~.Mobject.restore`."""
15931618 if hasattr (self , "saved_state" ):
15941619 # Prevent exponential growth of data
15951620 self .saved_state = None
@@ -1598,6 +1623,7 @@ def save_state(self):
15981623 return self
15991624
16001625 def restore (self ):
1626+ """Restores the state that was previously saved with :meth:`~.Mobject.save_state`."""
16011627 if not hasattr (self , "saved_state" ) or self .save_state is None :
16021628 raise Exception ("Trying to restore without having saved" )
16031629 self .become (self .saved_state )
@@ -1654,7 +1680,7 @@ def get_extremum_along_dim(self, points=None, dim=0, key=0):
16541680 return np .max (values )
16551681
16561682 def get_critical_point (self , direction ):
1657- """Picture a box bounding the mobject . Such a box has
1683+ """Picture a box bounding the :class:`~.Mobject` . Such a box has
16581684 9 'critical points': 4 corners, 4 edge center, the
16591685 center. This returns one of them, along the given direction.
16601686
@@ -1680,13 +1706,14 @@ def get_critical_point(self, direction):
16801706
16811707 # Pseudonyms for more general get_critical_point method
16821708
1683- def get_edge_center (self , direction ):
1709+ def get_edge_center (self , direction ) -> np . ndarray :
16841710 return self .get_critical_point (direction )
16851711
1686- def get_corner (self , direction ):
1712+ def get_corner (self , direction ) -> np . ndarray :
16871713 return self .get_critical_point (direction )
16881714
1689- def get_center (self ):
1715+ def get_center (self ) -> np .ndarray :
1716+ """Get center coordinates"""
16901717 return self .get_critical_point (np .zeros (self .dim ))
16911718
16921719 def get_center_of_mass (self ):
@@ -1697,16 +1724,20 @@ def get_boundary_point(self, direction):
16971724 index = np .argmax (np .dot (all_points , np .array (direction ).T ))
16981725 return all_points [index ]
16991726
1700- def get_top (self ):
1727+ def get_top (self ) -> np .ndarray :
1728+ """Get top coordinates of a box bounding the :class:`~.Mobject`"""
17011729 return self .get_edge_center (UP )
17021730
1703- def get_bottom (self ):
1731+ def get_bottom (self ) -> np .ndarray :
1732+ """Get bottom coordinates of a box bounding the :class:`~.Mobject`"""
17041733 return self .get_edge_center (DOWN )
17051734
1706- def get_right (self ):
1735+ def get_right (self ) -> np .ndarray :
1736+ """Get right coordinates of a box bounding the :class:`~.Mobject`"""
17071737 return self .get_edge_center (RIGHT )
17081738
1709- def get_left (self ):
1739+ def get_left (self ) -> np .ndarray :
1740+ """Get left coordinates of a box bounding the :class:`~.Mobject`"""
17101741 return self .get_edge_center (LEFT )
17111742
17121743 def get_zenith (self ):
@@ -1716,38 +1747,45 @@ def get_nadir(self):
17161747 return self .get_edge_center (IN )
17171748
17181749 def length_over_dim (self , dim ):
1750+ """Measure the length of an :class:`~.Mobject` in a certain direction."""
17191751 return self .reduce_across_dimension (
17201752 np .max , np .max , dim
17211753 ) - self .reduce_across_dimension (np .min , np .min , dim )
17221754
17231755 def get_coord (self , dim , direction = ORIGIN ):
1724- """Meant to generalize get_x, get_y, get_z"""
1756+ """Meant to generalize `` get_x``, `` get_y`` and `` get_z`` """
17251757 return self .get_extremum_along_dim (dim = dim , key = direction [dim ])
17261758
1727- def get_x (self , direction = ORIGIN ):
1759+ def get_x (self , direction = ORIGIN ) -> np .float64 :
1760+ """Returns x coordinate of the center of the :class:`~.Mobject` as ``float`` """
17281761 return self .get_coord (0 , direction )
17291762
1730- def get_y (self , direction = ORIGIN ):
1763+ def get_y (self , direction = ORIGIN ) -> np .float64 :
1764+ """Returns y coordinate of the center of the :class:`~.Mobject` as ``float`` """
17311765 return self .get_coord (1 , direction )
17321766
1733- def get_z (self , direction = ORIGIN ):
1767+ def get_z (self , direction = ORIGIN ) -> np .float64 :
1768+ """Returns z coordinate of the center of the :class:`~.Mobject` as ``float`` """
17341769 return self .get_coord (2 , direction )
17351770
17361771 def get_start (self ):
1772+ """Returns the point, where the stroke that surrounds the :class:`~.Mobject` starts."""
17371773 self .throw_error_if_no_points ()
17381774 if config ["use_opengl_renderer" ]:
17391775 return np .array (self .data ["points" ][0 ])
17401776 else :
17411777 return np .array (self .points [0 ])
17421778
17431779 def get_end (self ):
1780+ """Returns the point, where the stroke that surrounds the :class:`~.Mobject` ends."""
17441781 self .throw_error_if_no_points ()
17451782 if config ["use_opengl_renderer" ]:
17461783 return np .array (self .data ["points" ][- 1 ])
17471784 else :
17481785 return np .array (self .points [- 1 ])
17491786
17501787 def get_start_and_end (self ):
1788+ """Returns starting and ending point of a stroke as a ``tuple``. """
17511789 return self .get_start (), self .get_end ()
17521790
17531791 def point_from_proportion (self , alpha ):
@@ -1770,45 +1808,51 @@ def get_z_index_reference_point(self):
17701808 return z_index_group .get_center ()
17711809
17721810 def has_points (self ):
1811+ """Check if :class:`~.Mobject` contains points. """
17731812 return len (self .points ) > 0
17741813
17751814 def has_no_points (self ):
17761815 return not self .has_points ()
17771816
17781817 # Match other mobject properties
17791818
1780- def match_color (self , mobject ):
1819+ def match_color (self , mobject : "Mobject" ):
17811820 return self .set_color (mobject .get_color ())
17821821
1783- def match_dim_size (self , mobject , dim , ** kwargs ):
1822+ def match_dim_size (self , mobject : "Mobject" , dim , ** kwargs ):
17841823 return self .rescale_to_fit (mobject .length_over_dim (dim ), dim , ** kwargs )
17851824
1786- def match_width (self , mobject , ** kwargs ):
1825+ def match_width (self , mobject : "Mobject" , ** kwargs ):
17871826 return self .match_dim_size (mobject , 0 , ** kwargs )
17881827
1789- def match_height (self , mobject , ** kwargs ):
1828+ def match_height (self , mobject : "Mobject" , ** kwargs ):
17901829 return self .match_dim_size (mobject , 1 , ** kwargs )
17911830
1792- def match_depth (self , mobject , ** kwargs ):
1831+ def match_depth (self , mobject : "Mobject" , ** kwargs ):
17931832 return self .match_dim_size (mobject , 2 , ** kwargs )
17941833
1795- def match_coord (self , mobject , dim , direction = ORIGIN ):
1834+ def match_coord (self , mobject : "Mobject" , dim , direction = ORIGIN ):
17961835 return self .set_coord (
17971836 mobject .get_coord (dim , direction ),
17981837 dim = dim ,
17991838 direction = direction ,
18001839 )
18011840
1802- def match_x (self , mobject , direction = ORIGIN ):
1841+ def match_x (self , mobject : "Mobject" , direction = ORIGIN ):
18031842 return self .match_coord (mobject , 0 , direction )
18041843
1805- def match_y (self , mobject , direction = ORIGIN ):
1844+ def match_y (self , mobject : "Mobject" , direction = ORIGIN ):
18061845 return self .match_coord (mobject , 1 , direction )
18071846
1808- def match_z (self , mobject , direction = ORIGIN ):
1847+ def match_z (self , mobject : "Mobject" , direction = ORIGIN ):
18091848 return self .match_coord (mobject , 2 , direction )
18101849
1811- def align_to (self , mobject_or_point , direction = ORIGIN , alignment_vect = UP ):
1850+ def align_to (
1851+ self ,
1852+ mobject_or_point : Union ["Mobject" , np .ndarray , List ],
1853+ direction = ORIGIN ,
1854+ alignment_vect = UP ,
1855+ ):
18121856 """Examples:
18131857 mob1.align_to(mob2, UP) moves mob1 vertically so that its
18141858 top edge lines ups with mob2's top edge.
@@ -1865,7 +1909,7 @@ def family_members_with_points(self):
18651909
18661910 def arrange (
18671911 self ,
1868- direction = RIGHT ,
1912+ direction : Union [ np . ndarray , List ] = RIGHT ,
18691913 buff = DEFAULT_MOBJECT_TO_MOBJECT_BUFFER ,
18701914 center = True ,
18711915 ** kwargs ,
@@ -1952,7 +1996,7 @@ def align_data(self, mobject):
19521996 m1 .align_data (m2 )
19531997
19541998 def get_point_mobject (self , center = None ):
1955- """The simplest mobject to be transformed to or from self.
1999+ """The simplest :class:`~.Mobject` to be transformed to or from self.
19562000 Should by a point of the appropriate type
19572001 """
19582002 msg = f"get_point_mobject not implemented for { self .__class__ .__name__ } "
@@ -1980,7 +2024,7 @@ def align_submobjects(self, mobject):
19802024 return self
19812025
19822026 def null_point_align (self , mobject : "Mobject" ) -> "Mobject" :
1983- """If a mobject with points is being aligned to
2027+ """If a :class:`~.Mobject` with points is being aligned to
19842028 one without, treat both as groups, and push
19852029 the one with points into its own submobjects
19862030 list.
@@ -2024,7 +2068,7 @@ def repeat_submobject(self, submob):
20242068 return submob .copy ()
20252069
20262070 def interpolate (self , mobject1 , mobject2 , alpha , path_func = straight_path ):
2027- """Turns this mobject into an interpolation between ``mobject1``
2071+ """Turns this :class:`~.Mobject` into an interpolation between ``mobject1``
20282072 and ``mobject2``.
20292073
20302074 Examples
@@ -2061,7 +2105,7 @@ def pointwise_become_partial(self, mobject, a, b):
20612105
20622106 def become (self , mobject : "Mobject" , copy_submobjects : bool = True ):
20632107 """Edit points, colors and submobjects to be identical
2064- to another mobject
2108+ to another :class:`~.Mobject`
20652109
20662110 Examples
20672111 --------
@@ -2099,7 +2143,7 @@ def throw_error_if_no_points(self):
20992143
21002144 # About z-index
21012145 def set_z_index (self , z_index_value : Union [int , float ]):
2102- """Sets the mobject 's :attr:`z_index` to the value specified in `z_index_value`.
2146+ """Sets the :class:`~.Mobject` 's :attr:`z_index` to the value specified in `z_index_value`.
21032147
21042148 Parameters
21052149 ----------
@@ -2115,7 +2159,7 @@ def set_z_index(self, z_index_value: Union[int, float]):
21152159 return self
21162160
21172161 def set_z_index_by_z_coordinate (self ):
2118- """Sets the mobject 's z coordinate to the value of :attr:`z_index`.
2162+ """Sets the :class:`~.Mobject` 's z coordinate to the value of :attr:`z_index`.
21192163
21202164 Returns
21212165 -------
@@ -2128,7 +2172,7 @@ def set_z_index_by_z_coordinate(self):
21282172
21292173
21302174class Group (Mobject ):
2131- """Groups together multiple Mobjects ."""
2175+ """Groups together multiple :class:`~.Mobject`s ."""
21322176
21332177 def __init__ (self , * mobjects , ** kwargs ):
21342178 Mobject .__init__ (self , ** kwargs )
0 commit comments