Exemplo n.º 1
0
 def set_pixel_array(self, pixel_array, **kwargs):
     Camera.set_pixel_array(self, pixel_array, **kwargs)
     for shifted_camera in self.shifted_cameras:
         shifted_camera.camera.set_pixel_array(
             pixel_array[shifted_camera.start_y:shifted_camera.end_y,
                         shifted_camera.start_x:shifted_camera.end_x],
             **kwargs)
Exemplo n.º 2
0
 def set_pixel_array(self, pixel_array, **kwargs):
     Camera.set_pixel_array(self, pixel_array, **kwargs)
     for shifted_camera in self.shifted_cameras:
         shifted_camera.camera.set_pixel_array(
             pixel_array[
                 shifted_camera.start_y:shifted_camera.end_y,
                 shifted_camera.start_x:shifted_camera.end_x],
             **kwargs
         )
Exemplo n.º 3
0
 def capture_mobjects(self, mobjects, **kwargs):
     self.update_sub_cameras()
     for imfc in self.image_mobjects_from_cameras:
         to_add = list(mobjects)
         if not self.allow_cameras_to_capture_their_own_display:
             to_add = list_difference_update(
                 to_add, imfc.get_family()
             )
         imfc.camera.capture_mobjects(to_add, **kwargs)
     Camera.capture_mobjects(self, mobjects, **kwargs)
Exemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     Camera.__init__(self, *args, **kwargs)
     self.phi_tracker = ValueTracker(self.phi)
     self.theta_tracker = ValueTracker(self.theta)
     self.distance_tracker = ValueTracker(self.distance)
     self.gamma_tracker = ValueTracker(self.gamma)
     self.light_source = Point(self.light_source_start_point)
     self.frame_center = Point(self.frame_center)
     self.fixed_orientation_mobjects = dict()
     self.fixed_in_frame_mobjects = set()
     self.reset_rotation_matrix()
Exemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     Camera.__init__(self, *args, **kwargs)
     self.phi_tracker = ValueTracker(self.phi)
     self.theta_tracker = ValueTracker(self.theta)
     self.distance_tracker = ValueTracker(self.distance)
     self.gamma_tracker = ValueTracker(self.gamma)
     self.light_source = Point(self.light_source_start_point)
     self.frame_center = Point(self.frame_center)
     self.fixed_orientation_mobjects = dict()
     self.fixed_in_frame_mobjects = set()
     self.reset_rotation_matrix()
 def __init__(self, *cameras_with_start_positions, **kwargs):
     self.shifted_cameras = [
         DictAsObject(
             {
                 "camera": camera_with_start_positions[0],
                 "start_x": camera_with_start_positions[1][1],
                 "start_y": camera_with_start_positions[1][0],
                 "end_x": camera_with_start_positions[1][1] + camera_with_start_positions[0].get_pixel_width(),
                 "end_y": camera_with_start_positions[1][0] + camera_with_start_positions[0].get_pixel_height(),
             })
         for camera_with_start_positions in cameras_with_start_positions
     ]
     Camera.__init__(self, **kwargs)
Exemplo n.º 7
0
 def __init__(self, *cameras_with_start_positions, **kwargs):
     self.shifted_cameras = [
         DictAsObject(
             {
                 "camera": camera_with_start_positions[0],
                 "start_x": camera_with_start_positions[1][1],
                 "start_y": camera_with_start_positions[1][0],
                 "end_x": camera_with_start_positions[1][1] + camera_with_start_positions[0].get_pixel_width(),
                 "end_y": camera_with_start_positions[1][0] + camera_with_start_positions[0].get_pixel_height(),
             })
         for camera_with_start_positions in cameras_with_start_positions
     ]
     Camera.__init__(self, **kwargs)
Exemplo n.º 8
0
 def __init__(self, frame=None, **kwargs):
     """
     frame is a Mobject, (should almost certainly be a rectangle)
     determining which region of space the camera displys
     """
     digest_config(self, kwargs)
     if frame is None:
         frame = ScreenRectangle(height=FRAME_HEIGHT)
         frame.set_stroke(
             self.default_frame_stroke_color,
             self.default_frame_stroke_width,
         )
     self.frame = frame
     Camera.__init__(self, **kwargs)
 def capture_mobjects(self, mobjects, **kwargs):
     mobjects = self.get_mobjects_to_display(mobjects, **kwargs)
     if self.allow_object_intrusion:
         mobject_copies = mobjects
     else:
         mobject_copies = [mobject.copy() for mobject in mobjects]
     for mobject in mobject_copies:
         if isinstance(mobject, VMobject) and \
                 0 < mobject.get_num_curves() < self.min_num_curves:
             mobject.insert_n_curves(self.min_num_curves)
     Camera.capture_mobjects(
         self, mobject_copies,
         excluded_mobjects=None,
     )
Exemplo n.º 10
0
 def __init__(self, frame=None, **kwargs):
     """
     frame is a Mobject, (should almost certainly be a rectangle)
     determining which region of space the camera displys
     """
     digest_config(self, kwargs)
     if frame is None:
         frame = ScreenRectangle(height=FRAME_HEIGHT)
         frame.set_stroke(
             self.default_frame_stroke_color,
             self.default_frame_stroke_width,
         )
     self.frame = frame
     Camera.__init__(self, **kwargs)
Exemplo n.º 11
0
 def capture_mobjects(self, mobjects, **kwargs):
     mobjects = self.get_mobjects_to_display(mobjects, **kwargs)
     if self.allow_object_intrusion:
         mobject_copies = mobjects
     else:
         mobject_copies = [mobject.copy() for mobject in mobjects]
     for mobject in mobject_copies:
         if isinstance(mobject, VMobject) and \
                 0 < mobject.get_num_curves() < self.min_num_curves:
             mobject.insert_n_curves(self.min_num_curves)
     Camera.capture_mobjects(
         self, mobject_copies,
         include_submobjects=False,
         excluded_mobjects=None,
     )
Exemplo n.º 12
0
    def get_mobjects_to_display(self, *args, **kwargs):
        mobjects = Camera.get_mobjects_to_display(self, *args, **kwargs)
        rot_matrix = self.get_rotation_matrix()

        def z_key(mob):
            if not (hasattr(mob, "shade_in_3d") and mob.shade_in_3d):
                return np.inf
            # Assign a number to a three dimensional mobjects
            # based on how close it is to the camera
            return np.dot(mob.get_z_index_reference_point(), rot_matrix.T)[2]

        return sorted(mobjects, key=z_key)
Exemplo n.º 13
0
    def get_mobjects_to_display(self, *args, **kwargs):
        mobjects = Camera.get_mobjects_to_display(
            self, *args, **kwargs
        )
        rot_matrix = self.get_rotation_matrix()

        def z_key(mob):
            if not (hasattr(mob, "shade_in_3d") and mob.shade_in_3d):
                return np.inf
            # Assign a number to a three dimensional mobjects
            # based on how close it is to the camera
            return np.dot(
                mob.get_z_index_reference_point(),
                rot_matrix.T
            )[2]
        return sorted(mobjects, key=z_key)
Exemplo n.º 14
0
 def freeze_background(self):
     self.update_frame()
     self.set_camera(Camera(self.get_frame()))
     self.clear()
Exemplo n.º 15
0
 def always_sort_to_camera(self, camera: Camera):
     self.add_updater(lambda m: m.sort_faces_back_to_front(
         camera.get_location() - self.get_center()
     ))
Exemplo n.º 16
0
 def init_background(self):
     Camera.init_background(self)
     for shifted_camera in self.shifted_cameras:
         shifted_camera.camera.init_background()
Exemplo n.º 17
0
 def __init__(self, *image_mobjects_from_cameras, **kwargs):
     self.allow_cameras_to_capture_their_own_display=MultiCamera.CONFIG['allow_cameras_to_capture_their_own_display']
     self.image_mobjects_from_cameras = []
     for imfc in image_mobjects_from_cameras:
         self.add_image_mobject_from_camera(imfc)
     Camera.__init__(self, **kwargs)
Exemplo n.º 18
0
 def write_frame(self, camera: Camera) -> None:
     if self.write_to_movie:
         raw_bytes = camera.get_raw_fbo_data()
         self.writing_process.stdin.write(raw_bytes)
         if self.has_progress_display:
             self.progress_display.update()
Exemplo n.º 19
0
 def reset(self):
     for imfc in self.image_mobjects_from_cameras:
         imfc.camera.reset()
     Camera.reset(self)
     return self
Exemplo n.º 20
0
 def capture_mobjects(self, mobjects, **kwargs):
     self.reset_rotation_matrix()
     Camera.capture_mobjects(self, mobjects, **kwargs)
Exemplo n.º 21
0
 def get_image(self, camera=None):
     if camera is None:
         from manimlib.camera.camera import Camera
         camera = Camera()
     camera.capture_mobject(self)
     return camera.get_image()
Exemplo n.º 22
0
 def points_to_pixel_coords(self, points):
     return Camera.points_to_pixel_coords(self, np.apply_along_axis(self.mapping_func, 1, points))
Exemplo n.º 23
0
 def capture_mobjects(self, mobjects, **kwargs):
     # self.reset_frame_center()
     # self.realign_frame_shape()
     Camera.capture_mobjects(self, mobjects, **kwargs)
Exemplo n.º 24
0
 def init_background(self):
     Camera.init_background(self)
     for shifted_camera in self.shifted_cameras:
         shifted_camera.camera.init_background()
Exemplo n.º 25
0
 def capture_mobjects(self, mobjects, **kwargs):
     self.reset_rotation_matrix()
     Camera.capture_mobjects(self, mobjects, **kwargs)
Exemplo n.º 26
0
 def capture_mobjects(self, mobjects, **kwargs):
     # self.reset_frame_center()
     # self.realign_frame_shape()
     Camera.capture_mobjects(self, mobjects, **kwargs)
Exemplo n.º 27
0
 def get_image(self, camera=None):
     if camera is None:
         from manimlib.camera.camera import Camera
         camera = Camera()
     camera.capture_mobject(self)
     return camera.get_image()
Exemplo n.º 28
0
 def points_to_pixel_coords(self, points):
     return Camera.points_to_pixel_coords(self, np.apply_along_axis(self.mapping_func, 1, points))