5
5
__all__ = ["MultiCamera" ]
6
6
7
7
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
9
15
10
16
from ..camera .moving_camera import MovingCamera
11
17
from ..utils .iterables import list_difference_update
@@ -16,10 +22,10 @@ class MultiCamera(MovingCamera):
16
22
17
23
def __init__ (
18
24
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 :
23
29
"""Initialises the MultiCamera
24
30
25
31
Parameters
@@ -29,7 +35,7 @@ def __init__(
29
35
kwargs
30
36
Any valid keyword arguments of MovingCamera.
31
37
"""
32
- self .image_mobjects_from_cameras = []
38
+ self .image_mobjects_from_cameras : list [ ImageMobjectFromCamera ] = []
33
39
if image_mobjects_from_cameras is not None :
34
40
for imfc in image_mobjects_from_cameras :
35
41
self .add_image_mobject_from_camera (imfc )
@@ -38,7 +44,9 @@ def __init__(
38
44
)
39
45
super ().__init__ (** kwargs )
40
46
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 :
42
50
"""Adds an ImageMobject that's been obtained from the camera
43
51
into the list ``self.image_mobject_from_cameras``
44
52
@@ -53,20 +61,20 @@ def add_image_mobject_from_camera(self, image_mobject_from_camera: ImageMobject)
53
61
assert isinstance (imfc .camera , MovingCamera )
54
62
self .image_mobjects_from_cameras .append (imfc )
55
63
56
- def update_sub_cameras (self ):
64
+ def update_sub_cameras (self ) -> None :
57
65
"""Reshape sub_camera pixel_arrays"""
58
66
for imfc in self .image_mobjects_from_cameras :
59
67
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
+ # )
64
72
imfc .camera .reset_pixel_shape (
65
73
int (pixel_height * imfc .height / self .frame_height ),
66
74
int (pixel_width * imfc .width / self .frame_width ),
67
75
)
68
76
69
- def reset (self ):
77
+ def reset (self ) -> Self :
70
78
"""Resets the MultiCamera.
71
79
72
80
Returns
@@ -79,7 +87,7 @@ def reset(self):
79
87
super ().reset ()
80
88
return self
81
89
82
- def capture_mobjects (self , mobjects , ** kwargs ) :
90
+ def capture_mobjects (self , mobjects : Iterable [ Mobject ] , ** kwargs : Any ) -> None :
83
91
self .update_sub_cameras ()
84
92
for imfc in self .image_mobjects_from_cameras :
85
93
to_add = list (mobjects )
@@ -88,7 +96,7 @@ def capture_mobjects(self, mobjects, **kwargs):
88
96
imfc .camera .capture_mobjects (to_add , ** kwargs )
89
97
super ().capture_mobjects (mobjects , ** kwargs )
90
98
91
- def get_mobjects_indicating_movement (self ):
99
+ def get_mobjects_indicating_movement (self ) -> list [ Mobject ] :
92
100
"""Returns all mobjects whose movement implies that the camera
93
101
should think of all other mobjects on the screen as moving
94
102
0 commit comments