def __init__(self, **kwargs): # Force these dimensions self.camera_config = { "pixel_height": 1440, "pixel_width": 2560, } Scene.__init__(self, **kwargs)
def setup(self): 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 setup(self): 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 setup(self): """ This method is used internally by Manim to set up the scene for proper use. """ 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 compile_play_args_to_animation_list(self, *args, **kwargs): """ Add animations so that all pi creatures look at the first mobject being animated with each .play call """ animations = Scene.compile_play_args_to_animation_list( self, *args, **kwargs) anim_mobjects = Group(*[a.mobject for a in animations]) all_movers = anim_mobjects.get_family() if not self.any_pi_creatures_on_screen(): return animations pi_creatures = self.get_on_screen_pi_creatures() non_pi_creature_anims = [ anim for anim in animations if len( set(anim.mobject.get_family()).intersection(pi_creatures)) == 0 ] if len(non_pi_creature_anims) == 0: return animations # Get pi creatures to look at whatever # is being animated first_anim = non_pi_creature_anims[0] main_mobject = first_anim.mobject for pi_creature in pi_creatures: if pi_creature not in all_movers: animations.append( ApplyMethod( pi_creature.look_at, main_mobject, )) return animations
def compile_play_args_to_animation_list(self, *args, **kwargs): """ Add animations so that all pi creatures look at the first mobject being animated with each .play call """ animations = Scene.compile_play_args_to_animation_list( self, *args, **kwargs) if not self.any_pi_creatures_on_screen(): return animations pi_creatures = self.get_on_screen_pi_creatures() non_pi_creature_anims = [ anim for anim in animations if len( set(anim.mobject.get_family()).intersection(pi_creatures)) == 0 ] if len(non_pi_creature_anims) == 0: return animations # Get pi creatures to look at whatever # is being animated first_anim = non_pi_creature_anims[0] main_mobject = first_anim.mobject animations += [ UpdateFromAlphaFunc( pi_creature, lambda p, a: p.look_at( interpolate( p.get_look_at_spot(), main_mobject.get_center(), a, )), ) for pi_creature in pi_creatures ] return animations
def __new__(cls): kwargs = { "scene_name": manimlib.constants.LIVE_STREAM_NAME, "open_video_upon_completion": False, "show_file_in_finder": False, # By default, write to file "write_to_movie": True, "show_last_frame": False, "save_pngs": False, # If -t is passed in (for transparent), this will be RGBA "saved_image_mode": "RGB", "movie_file_extension": ".mp4", "quiet": True, "ignore_waits": False, "write_all": False, "name": manimlib.constants.LIVE_STREAM_NAME, "start_at_animation_number": 0, "end_at_animation_number": None, "skip_animations": False, "camera_config": manimlib.constants.HIGH_QUALITY_CAMERA_CONFIG, "livestreaming": True, "to_twitch": to_twitch, "twitch_key": twitch_key, } return Scene(**kwargs)
def compile_play_args_to_animation_list(self, *args, **kwargs): """ Add animations so that all pi creatures look at the first mobject being animated with each .play call """ animations = Scene.compile_play_args_to_animation_list(self, *args, **kwargs) if not self.any_pi_creatures_on_screen(): return animations pi_creatures = self.get_on_screen_pi_creatures() non_pi_creature_anims = [ anim for anim in animations if len(set(anim.mobject.get_family()).intersection(pi_creatures)) == 0 ] if len(non_pi_creature_anims) == 0: return animations # Get pi creatures to look at whatever # is being animated first_anim = non_pi_creature_anims[0] main_mobject = first_anim.mobject animations += [ UpdateFromAlphaFunc( pi_creature, lambda p, a: p.look_at( interpolate( p.get_look_at_spot(), main_mobject.get_center(), a, ) ), ) for pi_creature in pi_creatures ] return animations
def get_moving_mobjects(self, *animations): moving_mobjects = Scene.get_moving_mobjects(self, *animations) all_moving_mobjects = Mobject.extract_mobject_family_members( moving_mobjects) movement_indicators = self.camera.get_mobjects_indicating_movement() for movement_indicator in movement_indicators: if movement_indicator in all_moving_mobjects: # When one of these is moving, the camera should # consider all mobjects to be moving return list_update(self.submobjects, moving_mobjects) return moving_mobjects
def get_moving_mobjects(self, *animations): moving_mobjects = Scene.get_moving_mobjects(self, *animations) all_moving_mobjects = self.camera.extract_mobject_family_members( moving_mobjects ) movement_indicators = self.camera.get_mobjects_indicating_movement() for movement_indicator in movement_indicators: if movement_indicator in all_moving_mobjects: # When one of these is moving, the camera should # consider all mobjects to be moving return list_update(self.mobjects, moving_mobjects) return moving_mobjects
def get_moving_mobjects(self, *animations): """ This method returns a list of all of the Mobjects in the Scene that are moving, that are also in the animations passed. Parameters ---------- *animations (Animation) The animations whose mobjects will be checked. """ moving_mobjects = Scene.get_moving_mobjects(self, *animations) camera_mobjects = self.camera.get_value_trackers() if any([cm in moving_mobjects for cm in camera_mobjects]): return self.mobjects return moving_mobjects
def compile_play_args_to_animation_list(self, *args, **kwargs): """ Add animations so that all pi creatures look at the first mobject being animated with each .play call """ animations = Scene.compile_play_args_to_animation_list( self, *args, **kwargs) if not self.any_pi_creatures_on_screen(): return animations non_pi_creature_anims = [ anim for anim in animations if anim.mobject not in self.get_pi_creatures() ] if len(non_pi_creature_anims) == 0: return animations # Look at ending state first_anim = non_pi_creature_anims[0] first_anim_copy = copy.deepcopy(first_anim) first_anim_copy.begin() first_anim_copy.update(1) point_of_interest = first_anim_copy.mobject.get_center() for pi_creature in self.get_pi_creatures(): if pi_creature not in self.get_mobjects(): continue if pi_creature in first_anim.mobject.get_family(): continue anims_with_pi_creature = [ anim for anim in animations if pi_creature in anim.mobject.get_family() ] for anim in anims_with_pi_creature: if isinstance(anim, Transform): index = anim.mobject.get_family().index(pi_creature) target_family = anim.target_mobject.get_family() target = target_family[index] if isinstance(target, PiCreature): target.look_at(point_of_interest) if not anims_with_pi_creature: animations.append( ApplyMethod(pi_creature.look_at, point_of_interest)) return animations
def get_moving_mobjects(self, *animations): """ This method returns a list of all of the Mobjects in the Scene that are moving, that are also in the animations passed. Parameters ---------- *animations (Animation) The animations whose mobjects will be checked. """ moving_mobjects = Scene.get_moving_mobjects(self, *animations) all_moving_mobjects = self.camera.extract_mobject_family_members( moving_mobjects) movement_indicators = self.camera.get_mobjects_indicating_movement() for movement_indicator in movement_indicators: if movement_indicator in all_moving_mobjects: # When one of these is moving, the camera should # consider all mobjects to be moving return list_update(self.mobjects, moving_mobjects) return moving_mobjects
def clean_up_from_scene(self, scene: Scene) -> None: super().clean_up_from_scene(scene) if self.replace_mobject_with_target_in_scene: scene.remove(self.mobject) scene.add(self.target_mobject)
def non_blink_wait(self, time=1, **kwargs): Scene.wait(self, time, **kwargs) return self
def add(self, *mobjects): Scene.add(self, *list(mobjects) + self.foreground_mobjects)
def add_foreground_mobjects(self, *mobjects): self.foreground_mobjects += list(mobjects) Scene.add(self, *mobjects)
def non_blink_wait(self, time=1): Scene.wait(self, time) return self
def play(self, *animations, **kwargs): Scene.play( self, *list(animations) + list(map(Animation, self.foreground_mobjects)), **kwargs )
def clean_up_from_scene(self, scene: Scene) -> None: for anim in self.animations: anim.update(0) scene.remove(self.mobject) scene.remove(self.to_remove) scene.add(self.to_add)
def add(self, *mobjects): self.submobjects += list(mobjects) Scene.add(self, *mobjects)
def get_moving_mobjects(self, *animations): moving_mobjects = Scene.get_moving_mobjects(self, *animations) camera_mobjects = self.camera.get_value_trackers() if any([cm in moving_mobjects for cm in camera_mobjects]): return self.mobjects return moving_mobjects
def __init__(self, graph, *args, **kwargs): # See CubeGraph() above for format of graph self.graph = graph Scene.__init__(self, *args, **kwargs)
def clean_up_from_scene(self, scene: Scene) -> None: Animation.clean_up_from_scene(self, scene) scene.remove(self.mobject) self.mobject[0].restore() scene.add(self.to_add_on_completion)
def add(self, *mobjects): Scene.add(self, *list(mobjects) + self.submobjects)
def clean_up_from_scene(self, scene: Scene) -> None: if self.is_remover(): scene.remove(self.mobject)
def play(self, *animations, **kwargs): Scene.play(self, *list(animations) + list(map(Animation, self.submobjects)), **kwargs)