Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Adds MovingCameraScene

Grant Sandersonbbfce118f2fa
diff --git a/scene/moving_camera_scene.py b/scene/moving_camera_scene.py
new file mode 100644
index 000000000..5cb9696dd
--- /dev/null
+++ b/scene/moving_camera_scene.py
@@ -0,0 +1,23 @@
+from helpers import *
+
+from camera import MovingCamera
+from scene import Scene
+from topics.geometry import ScreenRectangle
+
+class MovingCameraScene(Scene):
+ def setup(self):
+ self.camera_frame = ScreenRectangle(height = 2*SPACE_HEIGHT)
+ self.camera_frame.set_stroke(width = 0)
+ self.camera = MovingCamera(
+ self.camera_frame, **self.camera_config
+ )
+ return self
+
+ def get_moving_mobjects(self, *animations):
+ # TODO: Code repetition from ZoomedScene
+ moving_mobjects = Scene.get_moving_mobjects(self, *animations)
+ if self.camera_frame in moving_mobjects:
+ # When the camera is moving, so is everything,
+ return self.mobjects
+ else:
+ return moving_mobjects
\ No newline at end of file
diff --git a/scene/zoomed_scene.py b/scene/zoomed_scene.py
index 52a7403d9..f7d49e650 100644
--- a/scene/zoomed_scene.py
+++ b/scene/zoomed_scene.py
@@ -122,6 +122,7 @@ class ZoomedScene(Scene):
self.zoomed_camera.capture_mobjects(
mobjects, **kwargs
)
+
def get_moving_mobjects(self, *animations):
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
if self.zoom_activated and self.little_rectangle in moving_mobjects: