A manim plugin providing the function play_timeline to play sequences of independent animations in parallel
Project description
Playing animations in a timeline
This plugin provides the function play_timeline()
which allows for launching several animations, at different instants, each one with a different duration, so that there can be several ones playing in parallel and finishing at different moments.
The interface is simple. You provide a dictionary whose keys are the timestamps at which each animations should start, and the values are the animations to play at those timestamps. It is possible to pass a list of animations for any given timestant, and in that case all those animations will start at once. The timestamps are relative to the time in which the whole timeline starts.
You can find a demo.py
in this folder, which runs a timeline in which:
- A progress bar increases linearly from timestamp 0 up to timestamp 12 (used as a reference)
- At timestamp 1, a Square is created during 10 secs
- At timestamp 2, a Circle and a Triangle are created, during 4 secs and 2 secs respectively
- At timestamp 9, a Text is written during 3 secs
This is the code:
class Test(Scene):
"""Example showing how to use play_timeline."""
def construct(self):
n = NumberLine(include_numbers=True, x_range=[0,12]).to_edge(DOWN)
self.add(n)
progress_bar = Line(n.n2p(0), n.n2p(12)).set_stroke(color=YELLOW, opacity=0.5, width=20)
# Create a timeline of animations. One of the animations is the progress bar itself
# going from 0 to 12 in 12 seconds. It can be used as a reference to check that
# the other animations are playing at the right time.
timeline = {
0: Create(progress_bar, run_time=12, rate_func=linear),
1: Create(Square(), run_time=10),
2: [Create(Circle(), run_time=4),
Create(Triangle(), run_time=2)],
9: Write(Text("It works!").next_to(progress_bar, UP, buff=1),
run_time=3)
}
play_timeline(self, timeline)
self.wait()
And this is the result:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file manim_play_timeline-0.1.0.tar.gz
.
File metadata
- Download URL: manim_play_timeline-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.2 Linux/5.4.0-162-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7c35fdbd0f77ab12400619aee4c73e554063b702e18f810bf20595bf809f804 |
|
MD5 | 0d4610f244d2addecab5a936e375f186 |
|
BLAKE2b-256 | 6c93e54b2bba7850a35a4c3c094e66f3331de2848b9274d708b4970b79dce2b7 |
File details
Details for the file manim_play_timeline-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: manim_play_timeline-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.2 Linux/5.4.0-162-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b9d62b9186d9719ecd54962d57a6874ca299d9f3e9335df13a81b3cdad9a994 |
|
MD5 | af22e85582fc619d5c03d0ffea466977 |
|
BLAKE2b-256 | 5a022ddd84605901fda4566a02cbb06a318b2c2e66af665dbb2a38af8d152135 |