Core R6 class representing an animation scene. Supports two APIs:
Pipe API (R-idiomatic):
scene("demo") %>% add_circle() %>% fade_in() %>% render()
Play API (Manim-style):
s <- Scene$new("demo")
c <- Circle$new()
s$add(c)
s$play(FadeIn$new(c))
s$render()
Public fields
name
Scene name/identifier
width
Scene width in pixels
height
Scene height in pixels
fps
Frames per second
background_color
Background color
objects
Named list of objects in the scene
timeline
Animation timeline (list of animation specs)
current_time
Current time in the scene
dimensions
"2D" or "3D"
camera
Camera object for the scene
updaters
List of scene-level updater functions
mobjects
Ordered list of visible mobjects (draw order)
Methods
Method new()
Create a new Scene
Usage
Scene$new(
name = "untitled",
width = 1920,
height = 1080,
fps = 30,
background_color = "#000000",
dimensions = "2D"
)
Arguments
name
Scene name
width
Width in pixels
height
Height in pixels
fps
Frames per second
background_color
Background color
dimensions
"2D" or "3D"
Method add()
Add mobject(s) to the scene (makes them visible).
Manim-compatible: scene$add(circle, square).
Arguments
...
MObjects to add to the scene
Remove mobject(s) from the scene.
Method play()
Play one or more Animation objects.
This is the primary Manim-style API for adding animations.
Arguments
...
Animation objects to play simultaneously
Wait (hold) for a duration. Manim-compatible.
Arguments
duration
Duration in seconds
Method add_object()
Add an object to the scene (legacy pipe API)
Usage
Scene$add_object(object, show_immediately = FALSE)
Arguments
object
A MObject to add
show_immediately
Whether to show the object immediately
Method add_animation()
Add an animation to the timeline (legacy pipe API)
Usage
Scene$add_animation(animation)
Arguments
animation
Animation specification (list)
Method get_object()
Get an object by ID
Method get_last_object()
Get the most recently added object
Method get_mobjects()
Get all mobjects currently in the scene
Method get_duration()
Calculate total duration
Method get_frame_count()
Get total number of frames
Method add_updater()
Add a scene-level updater function
Arguments
func
Function(scene, dt) called every frame
Method clear_updaters()
Remove all scene updaters
Process one frame of updaters
Method clear()
Clear the scene of all objects and animations
Method get_coord_to_pixel()
Get the coordinate-to-pixel conversion factors
Usage
Scene$get_coord_to_pixel()
Returns
List with x_scale and y_scale
Method clone()
The objects of this class are cloneable with this method.
Usage
Scene$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.