r"""Plays an animation in this scene. Parameters ---------- args Animations to be played. subcaption The content of the external subcaption that should be added during the animation. subcaption_duration The dur
(
self,
*args: Animation | Mobject | _AnimationBuilder,
subcaption: str | None = None,
subcaption_duration: float | None = None,
subcaption_offset: float = 0,
**kwargs: Any,
)
| 1145 | return run_time |
| 1146 | |
| 1147 | def play( |
| 1148 | self, |
| 1149 | *args: Animation | Mobject | _AnimationBuilder, |
| 1150 | subcaption: str | None = None, |
| 1151 | subcaption_duration: float | None = None, |
| 1152 | subcaption_offset: float = 0, |
| 1153 | **kwargs: Any, |
| 1154 | ) -> None: |
| 1155 | r"""Plays an animation in this scene. |
| 1156 | |
| 1157 | Parameters |
| 1158 | ---------- |
| 1159 | |
| 1160 | args |
| 1161 | Animations to be played. |
| 1162 | subcaption |
| 1163 | The content of the external subcaption that should |
| 1164 | be added during the animation. |
| 1165 | subcaption_duration |
| 1166 | The duration for which the specified subcaption is |
| 1167 | added. If ``None`` (the default), the run time of the |
| 1168 | animation is taken. |
| 1169 | subcaption_offset |
| 1170 | An offset (in seconds) for the start time of the |
| 1171 | added subcaption. |
| 1172 | kwargs |
| 1173 | All other keywords are passed to the renderer. |
| 1174 | |
| 1175 | """ |
| 1176 | # If we are in interactive embedded mode, make sure this is running on the main thread (required for OpenGL) |
| 1177 | if ( |
| 1178 | self.interactive_mode |
| 1179 | and config.renderer == RendererType.OPENGL |
| 1180 | and threading.current_thread().name != "MainThread" |
| 1181 | ): |
| 1182 | # TODO: are these actually being used? |
| 1183 | kwargs.update( |
| 1184 | { |
| 1185 | "subcaption": subcaption, |
| 1186 | "subcaption_duration": subcaption_duration, |
| 1187 | "subcaption_offset": subcaption_offset, |
| 1188 | } |
| 1189 | ) |
| 1190 | self.queue.put(SceneInteractRerun("play", **kwargs)) |
| 1191 | return |
| 1192 | |
| 1193 | start_time = self.time |
| 1194 | self.renderer.play(self, *args, **kwargs) |
| 1195 | run_time = self.time - start_time |
| 1196 | if subcaption: |
| 1197 | if subcaption_duration is None: |
| 1198 | subcaption_duration = run_time |
| 1199 | # The start of the subcaption needs to be offset by the |
| 1200 | # run_time of the animation because it is added after |
| 1201 | # the animation has already been played (and Scene.time |
| 1202 | # has already been updated). |
| 1203 | self.add_subcaption( |
| 1204 | content=subcaption, |