Skip to content

Commit f11c9a6

Browse files
committed
Merge branch 'opengl-tex' of github.com:eulertour/manim-1 into opengl-tex
2 parents b322bf2 + 3e3537d commit f11c9a6

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

manim/mobject/mobject.py

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class Mobject(Container):
5858
points : :class:`numpy.ndarray`
5959
The points of the objects.
6060
61+
.. seealso::
62+
63+
:class:`~.VMobject`
64+
6165
"""
6266

6367
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):
17581762
# Pseudonyms for more general get_critical_point method
17591763

17601764
def get_edge_center(self, direction) -> np.ndarray:
1765+
"""Get edge coordinates for certain direction."""
17611766
return self.get_critical_point(direction)
17621767

17631768
def get_corner(self, direction) -> np.ndarray:
1769+
"""Get corner coordinates for certain direction."""
17641770
return self.get_critical_point(direction)
17651771

17661772
def get_center(self) -> np.ndarray:
@@ -1791,10 +1797,12 @@ def get_left(self) -> np.ndarray:
17911797
"""Get left coordinates of a box bounding the :class:`~.Mobject`"""
17921798
return self.get_edge_center(LEFT)
17931799

1794-
def get_zenith(self):
1800+
def get_zenith(self) -> np.ndarray:
1801+
"""Get zenith coordinates of a box bounding a 3D :class:`~.Mobject`."""
17951802
return self.get_edge_center(OUT)
17961803

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`."""
17981806
return self.get_edge_center(IN)
17991807

18001808
def length_over_dim(self, dim):
@@ -1858,31 +1866,38 @@ def get_z_index_reference_point(self):
18581866
z_index_group = getattr(self, "z_index_group", self)
18591867
return z_index_group.get_center()
18601868

1861-
def has_points(self):
1869+
def has_points(self) -> bool:
18621870
"""Check if :class:`~.Mobject` contains points. """
18631871
return len(self.points) > 0
18641872

1865-
def has_no_points(self):
1873+
def has_no_points(self) -> bool:
1874+
"""Check if :class:`~.Mobject` *does not* contains points."""
18661875
return not self.has_points()
18671876

18681877
# Match other mobject properties
18691878

18701879
def match_color(self, mobject: "Mobject"):
1880+
"""Match the color with the color of another :class:`~.Mobject`."""
18711881
return self.set_color(mobject.get_color())
18721882

18731883
def match_dim_size(self, mobject: "Mobject", dim, **kwargs):
1884+
"""Match the specified dimension with the dimension of another :class:`~.Mobject`."""
18741885
return self.rescale_to_fit(mobject.length_over_dim(dim), dim, **kwargs)
18751886

18761887
def match_width(self, mobject: "Mobject", **kwargs):
1888+
"""Match the width with the width of another :class:`~.Mobject`."""
18771889
return self.match_dim_size(mobject, 0, **kwargs)
18781890

18791891
def match_height(self, mobject: "Mobject", **kwargs):
1892+
"""Match the height with the height of another :class:`~.Mobject`."""
18801893
return self.match_dim_size(mobject, 1, **kwargs)
18811894

18821895
def match_depth(self, mobject: "Mobject", **kwargs):
1896+
"""Match the depth with the depth of another :class:`~.Mobject`."""
18831897
return self.match_dim_size(mobject, 2, **kwargs)
18841898

18851899
def match_coord(self, mobject: "Mobject", dim, direction=ORIGIN):
1900+
"""Match the coordinates with the coordinates of another :class:`~.Mobject`."""
18861901
return self.set_coord(
18871902
mobject.get_coord(dim, direction),
18881903
dim=dim,
@@ -1893,7 +1908,7 @@ def match_x(self, mobject: "Mobject", direction=ORIGIN):
18931908
"""Match x coord. to the x coord. of another :class:`~.Mobject`."""
18941909
return self.match_coord(mobject, 0, direction)
18951910

1896-
def Match_y(self, mobject: "Mobject", direction=ORIGIN):
1911+
def match_y(self, mobject: "Mobject", direction=ORIGIN):
18971912
"""Match y coord. to the x coord. of another :class:`~.Mobject`."""
18981913
return self.match_coord(mobject, 1, direction)
18991914

@@ -1907,7 +1922,9 @@ def align_to(
19071922
direction=ORIGIN,
19081923
alignment_vect=UP,
19091924
):
1910-
"""Examples:
1925+
"""Aligns mobject to another :class:`~.Mobject` in a certain direction.
1926+
1927+
Examples:
19111928
mob1.align_to(mob2, UP) moves mob1 vertically so that its
19121929
top edge lines ups with mob2's top edge.
19131930
@@ -1992,6 +2009,21 @@ def construct(self):
19922009
return self
19932010

19942011
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+
19952027
submobs = self.submobjects
19962028
if n_rows is None and n_cols is None:
19972029
n_cols = int(np.sqrt(len(submobs)))
@@ -2013,12 +2045,14 @@ def arrange_in_grid(self, n_rows=None, n_cols=None, **kwargs):
20132045
return self
20142046

20152047
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``."""
20162049
if submob_func is None:
20172050
submob_func = lambda m: point_to_num_func(m.get_center())
20182051
self.submobjects.sort(key=submob_func)
20192052
return self
20202053

20212054
def shuffle(self, recursive=False):
2055+
"""Shuffles the list of :attr:`submobjects`."""
20222056
if recursive:
20232057
for submob in self.submobjects:
20242058
submob.shuffle(recursive=True)

manim/mobject/number_line.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def __init__(
5757
self.rotation = rotation
5858
self.tick_frequency = tick_frequency
5959
self.leftmost_tick = leftmost_tick
60-
self.numbers_with_elongated_ticks = numbers_with_elongated_ticks
6160
self.include_numbers = include_numbers
6261
self.numbers_to_show = numbers_to_show
6362
self.longer_tick_multiple = longer_tick_multiple
@@ -89,6 +88,12 @@ def __init__(
8988
self.unit_size = self.get_unit_size()
9089
self.shift(-self.number_to_point(self.number_at_center))
9190

91+
self.numbers_with_elongated_ticks = [
92+
nbr
93+
for nbr in numbers_with_elongated_ticks
94+
if self.x_min <= nbr <= self.x_max
95+
]
96+
9297
self.init_leftmost_tick()
9398
if self.include_tip:
9499
self.add_tip()

0 commit comments

Comments
 (0)