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(ambient_camera_rotation=None, default_angled_camera_orientation_kwargs=None): A scene seen through a 3D camera: shapes are projected, sorted by depth and shaded, as in Manim. The camera angles are trackers too (self.camera.phi_tracker)..set_camera_orientation(phi=None, theta=None, gamma=None, zoom=None, focal_distance=None, frame_center=None): Points the camera:phi(tilt from straight above),theta(turn around z),gamma,zoom,frame_center..move_camera(phi=None, theta=None, gamma=None, zoom=None, focal_distance=None, frame_center=None, added_anims=()): Animates the camera to new angles (with anyadded_animsat the same time)..begin_ambient_camera_rotation(rate=0.02, about="theta"): Keeps turning the camera slowly (rateradians per second,about="theta"or"phi")..stop_ambient_camera_rotation(about="theta"): Stops that turning..begin_3dillusion_camera_rotation(rate=1, origin_phi=None, origin_theta=None): Sways the camera in a small circle, which makes the scene look solid..stop_3dillusion_camera_rotation(): Stops the sway..set_to_default_angled_camera_orientation(): Tilts the camera to the usual 3D view (phi 70°, theta -135°)..add_fixed_in_frame_mobjects(*mobjects): Adds objects that stay flat on the screen (titles, captions), whatever the camera does..remove_fixed_in_frame_mobjects(*mobjects): Lets those objects turn with the camera again..add_fixed_orientation_mobjects(*mobjects, use_static_center_func=False, center_func=None): Adds objects placed in 3D that always face the camera (labels)..remove_fixed_orientation_mobjects(*mobjects): Lets those objects turn with the camera again.
SpecialThreeDScene(ambient_camera_rotation=None, default_angled_camera_orientation_kwargs=None): The same asThreeDScene.
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)