MCPcopy
hub / github.com/ManimCommunity/manim / Scene

Class Scene

manim/scene/scene.py:139–1948  ·  view source on GitHub ↗

A Scene is the canvas of your animation. The primary role of :class:`Scene` is to provide the user with tools to manage mobjects and animations. Generally speaking, a manim script consists of a class that derives from :class:`Scene` whose :meth:`Scene.construct` method is overridden

Source from the content-addressed store, hash-verified

137
138
139class Scene:
140 """A Scene is the canvas of your animation.
141
142 The primary role of :class:`Scene` is to provide the user with tools to manage
143 mobjects and animations. Generally speaking, a manim script consists of a class
144 that derives from :class:`Scene` whose :meth:`Scene.construct` method is overridden
145 by the user's code.
146
147 Mobjects are displayed on screen by calling :meth:`Scene.add` and removed from
148 screen by calling :meth:`Scene.remove`. All mobjects currently on screen are kept
149 in :attr:`Scene.mobjects`. Animations are played by calling :meth:`Scene.play`.
150
151 A :class:`Scene` is rendered internally by calling :meth:`Scene.render`. This in
152 turn calls :meth:`Scene.setup`, :meth:`Scene.construct`, and
153 :meth:`Scene.tear_down`, in that order.
154
155 It is not recommended to override the ``__init__`` method in user Scenes. For code
156 that should be ran before a Scene is rendered, use :meth:`Scene.setup` instead.
157
158 Examples
159 --------
160 Override the :meth:`Scene.construct` method with your code.
161
162 .. code-block:: python
163
164 class MyScene(Scene):
165 def construct(self):
166 self.play(Write(Text("Hello World!")))
167
168 """
169
170 def __init__(
171 self,
172 renderer: CairoRenderer | OpenGLRenderer | None = None,
173 camera_class: type[Camera] = Camera,
174 always_update_mobjects: bool = False,
175 random_seed: int | None = None,
176 skip_animations: bool = False,
177 ) -> None:
178 self.camera_class = camera_class
179 self.always_update_mobjects = always_update_mobjects
180 self.random_seed = random_seed if random_seed is not None else config.seed
181 self.skip_animations = skip_animations
182
183 self.animations: list[Animation] | None = None
184 self.stop_condition: Callable[[], bool] | None = None
185 self.moving_mobjects: list[Mobject] = []
186 self.static_mobjects: list[Mobject] = []
187 self.time_progression: tqdm[float] | None = None
188 self.duration: float = 0.0
189 self.last_t = 0.0
190 self.queue: Queue[SceneInteractAction] = Queue()
191 self.skip_animation_preview = False
192 self.meshes: list[Object3D] = []
193 self.camera_target = ORIGIN
194 self.widgets: list[dict[str, Any]] = []
195 self.dearpygui_imported = dearpygui_imported
196 self.updaters: list[Callable[[float], None]] = []

Calls

no outgoing calls