mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
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:
parent
f18a2b46e5
commit
def7241db3
1 changed files with 20 additions and 0 deletions
|
|
@ -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__(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue