Skip to content

Commit fc42710

Browse files
TheMathematicFanaticMrDiverpre-commit-ci[bot]
authored
Add Documentation to .to_edge and to_corner (#3408)
* Added docstrings and example renders to Mobject.to_corner() and Mobject.to_edge * Added docstrings and example renders to Mobject.to_corner() and Mobject.to_edge * Update manim/mobject/mobject.py * Update manim/mobject/mobject.py * Update manim/mobject/mobject.py * Update manim/mobject/mobject.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update manim/mobject/mobject.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Tristan Schulz <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 98a7f42 commit fc42710

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

manim/mobject/mobject.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,11 +1423,59 @@ def align_on_border(
14231423
def to_corner(
14241424
self, corner: Vector3 = DL, buff: float = DEFAULT_MOBJECT_TO_EDGE_BUFFER
14251425
) -> Self:
1426+
"""Moves this :class:`~.Mobject` to the given corner of the screen.
1427+
1428+
Returns
1429+
-------
1430+
:class:`.Mobject`
1431+
The newly positioned mobject.
1432+
1433+
Examples
1434+
--------
1435+
1436+
.. manim:: ToCornerExample
1437+
:save_last_frame:
1438+
1439+
class ToCornerExample(Scene):
1440+
def construct(self):
1441+
c = Circle()
1442+
c.to_corner(UR)
1443+
t = Tex("To the corner!")
1444+
t2 = MathTex("x^3").shift(DOWN)
1445+
self.add(c,t,t2)
1446+
t.to_corner(DL, buff=0)
1447+
t2.to_corner(UL, buff=1.5)
1448+
"""
14261449
return self.align_on_border(corner, buff)
14271450

14281451
def to_edge(
14291452
self, edge: Vector3 = LEFT, buff: float = DEFAULT_MOBJECT_TO_EDGE_BUFFER
14301453
) -> Self:
1454+
"""Moves this :class:`~.Mobject` to the given edge of the screen,
1455+
without affecting its position in the other dimension.
1456+
1457+
Returns
1458+
-------
1459+
:class:`.Mobject`
1460+
The newly positioned mobject.
1461+
1462+
Examples
1463+
--------
1464+
1465+
.. manim:: ToEdgeExample
1466+
:save_last_frame:
1467+
1468+
class ToEdgeExample(Scene):
1469+
def construct(self):
1470+
tex_top = Tex("I am at the top!")
1471+
tex_top.to_edge(UP)
1472+
tex_side = Tex("I am moving to the side!")
1473+
c = Circle().shift(2*DOWN)
1474+
self.add(tex_top, tex_side)
1475+
tex_side.to_edge(LEFT)
1476+
c.to_edge(RIGHT, buff=0)
1477+
1478+
"""
14311479
return self.align_on_border(edge, buff)
14321480

14331481
def next_to(

0 commit comments

Comments
 (0)