55__all__ = ["MultiCamera" ]
66
77
8- from manim .mobject .types .image_mobject import ImageMobject
8+ from collections .abc import Iterable
9+ from typing import Any
10+
11+ from typing_extensions import Self
12+
13+ from manim .mobject .mobject import Mobject
14+ from manim .mobject .types .image_mobject import ImageMobjectFromCamera
915
1016from ..camera .moving_camera import MovingCamera
1117from ..utils .iterables import list_difference_update
@@ -16,10 +22,10 @@ class MultiCamera(MovingCamera):
1622
1723 def __init__ (
1824 self ,
19- image_mobjects_from_cameras : ImageMobject | None = None ,
20- allow_cameras_to_capture_their_own_display = False ,
21- ** kwargs ,
22- ):
25+ image_mobjects_from_cameras : Iterable [ ImageMobjectFromCamera ] | None = None ,
26+ allow_cameras_to_capture_their_own_display : bool = False ,
27+ ** kwargs : Any ,
28+ ) -> None :
2329 """Initialises the MultiCamera
2430
2531 Parameters
@@ -29,7 +35,7 @@ def __init__(
2935 kwargs
3036 Any valid keyword arguments of MovingCamera.
3137 """
32- self .image_mobjects_from_cameras = []
38+ self .image_mobjects_from_cameras : list [ ImageMobjectFromCamera ] = []
3339 if image_mobjects_from_cameras is not None :
3440 for imfc in image_mobjects_from_cameras :
3541 self .add_image_mobject_from_camera (imfc )
@@ -38,7 +44,9 @@ def __init__(
3844 )
3945 super ().__init__ (** kwargs )
4046
41- def add_image_mobject_from_camera (self , image_mobject_from_camera : ImageMobject ):
47+ def add_image_mobject_from_camera (
48+ self , image_mobject_from_camera : ImageMobjectFromCamera
49+ ) -> None :
4250 """Adds an ImageMobject that's been obtained from the camera
4351 into the list ``self.image_mobject_from_cameras``
4452
@@ -53,20 +61,20 @@ def add_image_mobject_from_camera(self, image_mobject_from_camera: ImageMobject)
5361 assert isinstance (imfc .camera , MovingCamera )
5462 self .image_mobjects_from_cameras .append (imfc )
5563
56- def update_sub_cameras (self ):
64+ def update_sub_cameras (self ) -> None :
5765 """Reshape sub_camera pixel_arrays"""
5866 for imfc in self .image_mobjects_from_cameras :
5967 pixel_height , pixel_width = self .pixel_array .shape [:2 ]
60- imfc .camera .frame_shape = (
61- imfc .camera .frame .height ,
62- imfc .camera .frame .width ,
63- )
68+ # imfc.camera.frame_shape = (
69+ # imfc.camera.frame.height,
70+ # imfc.camera.frame.width,
71+ # )
6472 imfc .camera .reset_pixel_shape (
6573 int (pixel_height * imfc .height / self .frame_height ),
6674 int (pixel_width * imfc .width / self .frame_width ),
6775 )
6876
69- def reset (self ):
77+ def reset (self ) -> Self :
7078 """Resets the MultiCamera.
7179
7280 Returns
@@ -79,7 +87,7 @@ def reset(self):
7987 super ().reset ()
8088 return self
8189
82- def capture_mobjects (self , mobjects , ** kwargs ) :
90+ def capture_mobjects (self , mobjects : Iterable [ Mobject ] , ** kwargs : Any ) -> None :
8391 self .update_sub_cameras ()
8492 for imfc in self .image_mobjects_from_cameras :
8593 to_add = list (mobjects )
@@ -88,7 +96,7 @@ def capture_mobjects(self, mobjects, **kwargs):
8896 imfc .camera .capture_mobjects (to_add , ** kwargs )
8997 super ().capture_mobjects (mobjects , ** kwargs )
9098
91- def get_mobjects_indicating_movement (self ):
99+ def get_mobjects_indicating_movement (self ) -> list [ Mobject ] :
92100 """Returns all mobjects whose movement implies that the camera
93101 should think of all other mobjects on the screen as moving
94102
0 commit comments