mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 06:37:44 +00:00
Some bug fixes to ZoomedScene
This commit is contained in:
parent
2981fa2b32
commit
a982b3c1ac
2 changed files with 20 additions and 11 deletions
|
|
@ -1,19 +1,20 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from constants import *
|
||||
|
||||
from scene.scene import Scene
|
||||
from camera.moving_camera import MovingCamera
|
||||
from mobject.frame import ScreenRectangle
|
||||
|
||||
|
||||
class MovingCameraScene(Scene):
|
||||
CONFIG = {
|
||||
"camera_class": MovingCamera
|
||||
}
|
||||
|
||||
def setup(self):
|
||||
self.camera_frame = ScreenRectangle(height=FRAME_HEIGHT)
|
||||
self.camera_frame.set_stroke(width=0)
|
||||
self.camera = MovingCamera(
|
||||
self.camera_frame, **self.camera_config
|
||||
)
|
||||
Scene.setup(self)
|
||||
assert(isinstance(self.camera, MovingCamera))
|
||||
self.camera_frame = self.camera.frame
|
||||
# Hmm, this currently relies on the fact that MovingCamera
|
||||
# willd default to a full-sized frame. Is that okay?
|
||||
return self
|
||||
|
||||
def get_moving_mobjects(self, *animations):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from scene.scene import Scene
|
||||
from scene.moving_camera_scene import MovingCameraScene
|
||||
from camera.moving_camera import MovingCamera
|
||||
from camera.multi_camera import MultiCamera
|
||||
from mobject.types.image_mobject import ImageMobjectFromCamera
|
||||
from utils.simple_functions import fdiv
|
||||
|
||||
from constants import *
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ from constants import *
|
|||
# Note, any scenes from old videos using ZoomedScene will almost certainly
|
||||
# break, as it was restructured.
|
||||
|
||||
class ZoomedScene(Scene):
|
||||
class ZoomedScene(MovingCameraScene):
|
||||
CONFIG = {
|
||||
"camera_class": MultiCamera,
|
||||
"zoomed_display_height": 3,
|
||||
|
|
@ -30,6 +31,7 @@ class ZoomedScene(Scene):
|
|||
}
|
||||
|
||||
def setup(self):
|
||||
MovingCameraScene.setup(self)
|
||||
# Initialize camera and display
|
||||
zoomed_camera = MovingCamera(**self.zoomed_camera_config)
|
||||
zoomed_display = ImageMobjectFromCamera(
|
||||
|
|
@ -80,7 +82,7 @@ class ZoomedScene(Scene):
|
|||
self.add_foreground_mobjects(*to_add)
|
||||
|
||||
def get_moving_mobjects(self, *animations):
|
||||
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
|
||||
moving_mobjects = MovingCameraScene.get_moving_mobjects(self, *animations)
|
||||
zoomed_mobjects = [self.zoomed_camera.frame, self.zoomed_display]
|
||||
moving_zoomed_mobjects = set(moving_mobjects).intersection(zoomed_mobjects)
|
||||
if self.zoom_activated and moving_zoomed_mobjects:
|
||||
|
|
@ -88,3 +90,9 @@ class ZoomedScene(Scene):
|
|||
# everything
|
||||
return self.mobjects
|
||||
return moving_mobjects
|
||||
|
||||
def get_zoom_factor(self):
|
||||
return fdiv(
|
||||
self.zoomed_camera.frame.get_width(),
|
||||
self.zoomed_display.get_width()
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue