Add Homotopy example for waving square (#4100)

* Add missing changes for homotopy example

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Irvanal Haq 2025-01-19 22:38:30 +07:00 committed by GitHub
commit def7241db3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,6 +44,26 @@ class Homotopy(Animation):
Keyword arguments propagated to :meth:`.Mobject.apply_function`.
kwargs
Further keyword arguments passed to the parent class.
Examples
--------
.. manim:: HomotopyExample
class HomotopyExample(Scene):
def construct(self):
square = Square()
def homotopy(x, y, z, t):
if t <= 0.25:
progress = t / 0.25
return (x, y + progress * 0.2 * np.sin(x), z)
else:
wave_progress = (t - 0.25) / 0.75
return (x, y + 0.2 * np.sin(x + 10 * wave_progress), z)
self.play(Homotopy(homotopy, square, rate_func= linear, run_time=2))
"""
def __init__(