Reference: Scenes, Config and the Camera
Scripts, scenes, sound, settings, camera.
A script without a Scene class
See Scenes and sections for a guide.
play(*animations): Plays animations on the file's timeline, in a script without a Scene class. Pymations extra (not in Manim).wait(duration=DEFAULT_WAIT_TIME): Holds the picture (1 s unless you say), in a script without a Scene class. Pymations extra (not in Manim).add(*mobjects): Puts objects on screen at once, in a script without a Scene class. Pymations extra (not in Manim).remove(*mobjects): Takes objects off screen at once, in a script without a Scene class. Pymations extra (not in Manim).clear(): Takes everything off screen, in a script without a Scene class. Pymations extra (not in Manim).section(name, sound=None, transition=None, transition_time=None): Starts a named section of the timeline (a tick on the scrubber).sound=plays a voice-over and makes the section last at least as long as it;transition=changes from the previous picture to the new one:"crossfade","slide_left","slide_right"or"wipe", overtransition_timeseconds (0.5). Pymations extra (not in Manim).
Scenes
Scene(): A scene:construct()says what happens. Every scene in a file plays, in order, each as a section..setup(): Runs beforeconstruct()..construct(): Write the scene here..tear_down(): Runs afterconstruct()..render(preview=False): Plays the scene; ascene.render()at the end of a pasted script is fine..add(*mobjects)(also.add_foreground_mobjects,.add_foreground_mobject): Puts objects on screen at once, without animating; one already there moves to the front..remove(*mobjects)(also.remove_foreground_mobjects,.remove_foreground_mobject): Takes objects off screen at once..clear(): Takes everything off screen..bring_to_front(*mobjects): Draws objects above everything else..bring_to_back(*mobjects): Draws objects below everything else..play(*animations, run_time=None, rate_func=None, lag_ratio=None): Plays animations together;run_time,rate_funcandlag_ratiohere apply to each of them..wait(duration=DEFAULT_WAIT_TIME, stop_condition=None, frozen_frame=None)(also.pause): Holds the picture (1 s unless you say)..wait_until(stop_condition, max_time=60): Waits up tomax_timeseconds..next_section(name="unnamed", section_type=None, skip_animations=False, sound=None): Starts a named section: a tick on the timeline.sound=plays a voice-over for it..add_sound(sound_file, time_offset=0, gain=None): Plays a sound from this point of the timeline (gainin dB)..music(sound_file): Background music under the timeline from here, quiet and looping. Pymations extra (not in Manim)..wait_for_sound(sound=None, extra=0): Waits until a sound (or the last one started) has finished, plusextraseconds. Pymations extra (not in Manim)..interactive_embed()(also.embed): Skipped.
MovingCameraScene(): A scene whose camera can move:self.camera.frame.animate….ZoomedScene(): Accepted; plays as aMovingCameraScene.ThreeDScene(): Accepted so 3D scripts run; plays flat, in 2D..set_camera_orientation(): Skipped with a note (no 3D view yet)..move_camera(added_anims=(), run_time=None): Plays anyadded_anims; the camera turn is skipped with a note..begin_ambient_camera_rotation(): Skipped with a note..stop_ambient_camera_rotation(): Skipped..set_to_default_angled_camera_orientation(): Skipped with a note..add_fixed_in_frame_mobjects(*mobjects)(also.add_fixed_orientation_mobjects): Adds objects (all objects are flat already).
Sound
Sounds are mixed into a recorded video. The file name is next to your .py file.
add_sound(sound_file, time_offset=0, gain=None): Plays a sound from this point of the timeline (gainin dB), in a script without a Scene class.music(sound_file, volume=0.3, fade_in=0, fade_out=1, loop=True): Background music under the timeline from here:volume0 to 1, fading in and out, looping. Pymations extra (not in Manim).wait_for_sound(sound=None, extra=0): Waits until a sound (or the last one started) has finished, plusextraseconds. Pymations extra (not in Manim).
from pymations import *
music("bed.mp3", volume=0.2)
section("Intro", sound="intro-voice.mp3")
play(Write(Text("Hello")))
wait_for_sound()
Settings and helpers
config: Settings for the whole file:config.background_color,config.frame_height(8),config.frame_width,config.transition(how every section begins:"crossfade","slide_left","slide_right","wipe", or"none") andconfig.transition_time(0.5);config(background_color=WHITE)sets several.camera: The camera in a script without a Scene class:camera.frame,camera.background_color.CameraFrame(): The camera's view, ascamera.frameorself.camera.frame; animate it to zoom and pan.np: numpy asfrom manim import *gives it: the real numpy when the Python has it, else the parts scene scripts use (np.sin,np.array,np.linspace…).rate_functions: All the rate functions by name:rate_functions.smooth.
from pymations import *
config.background_color = "#14213d"
play(camera.frame.animate.scale(0.5), run_time=2)