-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
12 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,75 @@ | ||
movement | ||
======== | ||
|
||
.. automodule:: janim.anims.movement | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
.. autoclass:: janim.anims.movement.Homotopy | ||
:show-inheritance: | ||
|
||
.. janim-example:: HomotopyExample | ||
:media: ../../_static/videos/HomotopyExample.mp4 | ||
|
||
from janim.imports import * | ||
|
||
class HomotopyExample(Timeline): | ||
def construct(self): | ||
def homotopy_func(x, y, z, t): | ||
return [x * t, y * t, z] | ||
|
||
square = Square() | ||
self.play(Homotopy(square, homotopy_func)) | ||
self.forward(0.3) | ||
|
||
.. autoclass:: janim.anims.movement.ComplexHomotopy | ||
:show-inheritance: | ||
|
||
.. janim-example:: ComplexHomotopyExample | ||
:media: ../../_static/videos/ComplexHomotopyExample.mp4 | ||
|
||
from janim.imports import * | ||
|
||
class ComplexHomotopyExample(Timeline): | ||
def construct(self): | ||
def complex_func(z: complex, t: float) -> complex: | ||
return interpolate(z, z**3, t) | ||
|
||
group = Group( | ||
Text('Text'), | ||
Square(side_length=1), | ||
) | ||
group.points.arrange(RIGHT, buff=2) | ||
|
||
self.play( | ||
*[ComplexHomotopy( | ||
item, | ||
complex_func | ||
) for item in group] | ||
) | ||
self.forward(0.3) | ||
.. autoclass:: janim.anims.movement.MoveAlongPath | ||
:show-inheritance: | ||
|
||
.. janim-example:: MoveAlongPathExample | ||
:media: ../../_static/videos/MoveAlongPathExample.mp4 | ||
|
||
from janim.imports import * | ||
|
||
class MoveAlongPathExample(Timeline): | ||
def construct(self) -> None: | ||
line = Line(ORIGIN, RIGHT * Config.get.frame_width, buff=1) | ||
dot1 = Dot(color=YELLOW) | ||
|
||
curve = ParametricCurve( | ||
lambda t: [math.cos(t) * t * 0.2, math.sin(t) * t * 0.2, 0], | ||
(0, 10, 0.1) | ||
) | ||
dot2 = Dot(color=YELLOW) | ||
|
||
group = Group(line, curve).show() | ||
group.points.arrange(DOWN) | ||
|
||
self.play( | ||
MoveAlongPath(dot1, line), | ||
MoveAlongPath(dot2, curve), | ||
duration=2 | ||
) | ||
self.forward(0.3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters