Getting Started¶
Note
Before proceeding, install Algan and make sure it is running properly by following the detailed steps in Installation.
Your First Algan Program¶
The simplest way to use Algan is to write a Python script and run it.
Let’s make a very simple animation. Create a new file named my_first_algan.py,
and copy this code into it:
Example: GettingStartedHelloWorld ¶
from algan import *
text = Text('Hello World!', font_size=100)
text.spawn()
text.wait(1)
text.despawn()
Scene.save_video("my_video")
Now run the script from your terminal using python my_first_algan.py.
If the execution is successful, you should find a new directory named
algan_outputs in the same directory as your Python script, and inside of that
directory there should be a video file my_video.mp4. Open this video file,
and you will see your first Algan animation playing: “Hello World!” appearing on
screen.
Explanation¶
Let’s break down this minimal program line-by-line to see what’s going on:
from algan import *
This line imports all of Algan’s functionality, making it available to use in your script. All of your Algan scripts will start with this line.
The next line
text = Text('Hello World!', font_size=100)
creates a Text object. In Algan, any object that can be animated and appears on screen is
called a Mob (short for Moveable Object). Here, we create a Text object,
which is a type of Mob that displays text. We initialize it with the content “Hello World!”
and a font size of 100. This mob is then assigned the name text so we can
refer to it later in the script.
text.spawn()
This line spawns the mob we previously created. This step is crucial as mobs will not appear on screen,
and will not be animatable, until they have been spawned. By default, a mob will play a simple fade-in animation
when it is spawned. Without calling spawn(), your Mob will not appear in the final video.
text.wait(1)
This line uses wait() with a value of 1 to do… nothing! The mob waits unchanged for one second.
text.despawn()
And this despawns the mob, removing it from the scene with a simple fade-out animation. Mobs do not need to be despawned, and if they are not despawned they will stick around until the end of the video.
Scene.save_video("my_video")
This final line instructs Algan to process all of the previously created mobs and animations you’ve defined in your script and render them into a video file with the given name.
See also
Text and Mathematics – everything
Text can do, plus LaTeX with
Tex, per-glyph animation, the hand-writing effect
and animated numbers.
Where To Next¶
Basic Animations – continue with the new-user tutorials to learn about animating mobs.
The Mob Gallery – see all of Algan’s available mobs.
Saving Videos and Images – customize the output file and the video quality.