def __init__(self, background=None, **kwargs): digest_config(self, kwargs, locals()) self.rgb_max_val = np.iinfo(self.pixel_array_dtype).max self.pixel_array_to_cairo_context = {} self.init_background() self.resize_frame_shape() self.reset()
def __init__(self, **kwargs): digest_config(self, kwargs) videos = [VideoIcon() for x in range(self.num_videos)] VGroup.__init__(self, *videos, **kwargs) self.arrange() self.set_width(FRAME_WIDTH - MED_LARGE_BUFF) self.set_color_by_gradient(*self.gradient_colors)
def __init__(self, pi_creature, *content, **kwargs): digest_config(self, kwargs) bubble = pi_creature.get_bubble( *content, bubble_class=self.bubble_class, **self.bubble_kwargs ) Group(bubble, bubble.content).shift_onto_screen() pi_creature.generate_target() pi_creature.target.change_mode(self.target_mode) if self.look_at_arg is not None: pi_creature.target.look_at(self.look_at_arg) change_mode = MoveToTarget(pi_creature, **self.change_mode_kwargs) bubble_creation = self.bubble_creation_class( bubble, **self.bubble_creation_kwargs ) content_introduction = self.content_introduction_class( bubble.content, **self.content_introduction_kwargs ) AnimationGroup.__init__( self, change_mode, bubble_creation, content_introduction, **kwargs )
def __init__(self, **kwargs): digest_config(self, kwargs) Rectangle.__init__( self, width=self.aspect_ratio * self.height, height=self.height, **kwargs )
def __init__(self, **kwargs): digest_config(self, kwargs) Rectangle.__init__( self, height=self.side_length, width=self.side_length, **kwargs )
def __init__(self, mobject, mode="linear", **kwargs): if not isinstance(mobject, PiCreatureClass): raise Exception("FlashThroughClass mobject must be a PiCreatureClass") digest_config(self, kwargs) self.indices = list(range(mobject.height * mobject.width)) if mode == "random": np.random.shuffle(self.indices) Animation.__init__(self, mobject, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) if self.camera_config["pixel_width"] == PRODUCTION_QUALITY_CAMERA_CONFIG["pixel_width"]: config = {} else: config = self.low_quality_config config = merge_dicts_recursively(config, kwargs) ThreeDScene.__init__(self, **config)
def __init__(self, n=6, **kwargs): digest_config(self, kwargs, locals()) if self.start_angle is None: if n % 2 == 0: self.start_angle = 0 else: self.start_angle = 90 * DEGREES start_vect = rotate_vector(RIGHT, self.start_angle) vertices = compass_directions(n, start_vect) Polygon.__init__(self, *vertices, **kwargs)
def __init__(self, *tex_strings, **kwargs): digest_config(self, kwargs) tex_strings = self.break_up_tex_strings(tex_strings) self.tex_strings = tex_strings SingleStringTexMobject.__init__( self, self.arg_separator.join(tex_strings), **kwargs ) self.break_up_by_substrings() self.set_color_by_tex_to_color_map(self.tex_to_color_map) if self.organize_left_to_right: self.organize_submobjects_left_to_right()
def __init__(self, pi_creature=None, **kwargs): digest_config(self, kwargs) SVGMobject.__init__(self, file_name=self.file_name, **kwargs) self.stretch(self.y_stretch_factor, 1) self.set_height(self.height) self.set_stroke(width=0) self.set_fill(color=self.color) if pi_creature is not None: eyes = pi_creature.eyes self.set_height(3 * eyes.get_height()) self.move_to(eyes, DOWN) self.shift(DOWN * eyes.get_height() / 4)
def __init__(self, filename_or_array, **kwargs): digest_config(self, kwargs) if isinstance(filename_or_array, str): path = get_full_raster_image_path(filename_or_array) image = Image.open(path).convert(self.image_mode) self.pixel_array = np.array(image) else: self.pixel_array = np.array(filename_or_array) self.change_to_rgba_array() if self.invert: self.pixel_array[:, :, :3] = 255 - self.pixel_array[:, :, :3] AbstractImageMobject.__init__(self, **kwargs)
def __init__(self, tex_string, **kwargs): digest_config(self, kwargs) assert(isinstance(tex_string, str)) self.tex_string = tex_string file_name = tex_to_svg_file( self.get_modified_expression(tex_string), self.template_tex_file_body ) SVGMobject.__init__(self, file_name=file_name, **kwargs) if self.height is None: self.scale(TEX_MOB_SCALE_FACTOR) if self.organize_left_to_right: self.organize_submobjects_left_to_right()
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 __init__(self, **kwargs): digest_config(self, kwargs) start = self.unit_size * self.x_min * RIGHT end = self.unit_size * self.x_max * RIGHT Line.__init__(self, start, end, **kwargs) self.shift(-self.number_to_point(self.number_at_center)) self.init_leftmost_tick() if self.include_tip: self.add_tip() if self.include_ticks: self.add_tick_marks() if self.include_numbers: self.add_numbers()
def __init__(self, vmobject, **kwargs): digest_config(self, kwargs) max_stroke_width = vmobject.get_stroke_width() max_time_width = kwargs.pop("time_width", self.time_width) AnimationGroup.__init__(self, *[ ShowPassingFlash( vmobject.deepcopy().set_stroke(width=stroke_width), time_width=time_width, **kwargs ) for stroke_width, time_width in zip( np.linspace(0, max_stroke_width, self.n_segments), np.linspace(max_time_width, 0, self.n_segments) ) ])
def __init__(self, pi_creature, **kwargs): assert hasattr(pi_creature, "bubble") digest_config(self, kwargs, locals()) pi_creature.generate_target() pi_creature.target.change_mode(self.target_mode) if self.look_at_arg is not None: pi_creature.target.look_at(self.look_at_arg) AnimationGroup.__init__( self, MoveToTarget(pi_creature), FadeOut(pi_creature.bubble), FadeOut(pi_creature.bubble.content), )
def __init__(self, left_camera, right_camera, **kwargs): digest_config(self, kwargs) self.left_camera = left_camera self.right_camera = right_camera half_width = self.get_pixel_width() / 2 for camera in [self.left_camera, self.right_camera]: # TODO: Round up on one if width is odd camera.reset_pixel_shape(camera.get_pixel_height(), half_width) OldMultiCamera.__init__( self, (left_camera, (0, 0)), (right_camera, (0, half_width)), )
def __init__(self, suit_name, **kwargs): digest_config(self, kwargs) suits_to_colors = { "hearts": self.red, "diamonds": self.red, "spades": self.black, "clubs": self.black, } if suit_name not in suits_to_colors: raise Exception("Invalid suit name") SVGMobject.__init__(self, file_name=suit_name, **kwargs) color = suits_to_colors[suit_name] self.set_stroke(width=0) self.set_fill(color, 1) self.set_height(self.height)
def __init__(self, **kwargs): digest_config(self, kwargs, locals()) if self.file_name is None: raise Exception("Must invoke Bubble subclass") try: SVGMobject.__init__(self, **kwargs) except IOError as err: self.file_name = os.path.join(FILE_DIR, self.file_name) SVGMobject.__init__(self, **kwargs) self.center() self.stretch_to_fit_height(self.height) self.stretch_to_fit_width(self.width) if self.direction[0] > 0: Mobject.flip(self) self.direction_was_specified = ("direction" in kwargs) self.content = Mobject()
def __init__(self, mobject, direction=DOWN, **kwargs): digest_config(self, kwargs, locals()) angle = -np.arctan2(*direction[:2]) + np.pi mobject.rotate(-angle, about_point=ORIGIN) left = mobject.get_corner(DOWN + LEFT) right = mobject.get_corner(DOWN + RIGHT) target_width = right[0] - left[0] # Adding int(target_width) qquads gives approximately the right width num_quads = np.clip( int(self.width_multiplier * target_width), self.min_num_quads, self.max_num_quads ) tex_string = "\\underbrace{%s}" % (num_quads * "\\qquad") TexMobject.__init__(self, tex_string, **kwargs) self.tip_point_index = np.argmin(self.get_all_points()[:, 1]) self.stretch_to_fit_width(target_width) self.shift(left - self.get_corner(UP + LEFT) + self.buff * DOWN) for mob in mobject, self: mob.rotate(angle, about_point=ORIGIN)
def __init__(self, start_anim, end_anim, **kwargs): digest_config(self, kwargs, locals()) if "run_time" in kwargs: self.run_time = kwargs.pop("run_time") else: self.run_time = max(start_anim.run_time, end_anim.run_time) for anim in start_anim, end_anim: anim.set_run_time(self.run_time) if start_anim.starting_mobject.get_num_points() != end_anim.starting_mobject.get_num_points(): start_anim.starting_mobject.align_data(end_anim.starting_mobject) for anim in start_anim, end_anim: if hasattr(anim, "target_mobject"): anim.starting_mobject.align_data(anim.target_mobject) Transform.__init__(self, start_anim.mobject, end_anim.mobject, **kwargs) # Rewire starting and ending mobjects start_anim.mobject = self.starting_mobject end_anim.mobject = self.target_mobject
def __init__(self, focal_point, **kwargs): digest_config(self, kwargs) circles = VGroup() for x in range(self.n_circles): circle = Circle( radius=self.big_radius, stroke_color=BLACK, stroke_width=0, ) circle.add_updater( lambda c: c.move_to(focal_point) ) circle.save_state() circle.set_width(self.small_radius * 2) circle.set_stroke(self.color, self.start_stroke_width) circles.add(circle) animations = [ Restore(circle) for circle in circles ] super().__init__(*animations, **kwargs)
def __init__(self, clock, **kwargs): digest_config(self, kwargs) assert(isinstance(clock, Clock)) rot_kwargs = { "axis": OUT, "about_point": clock.get_center() } hour_radians = -self.hours_passed * 2 * np.pi / 12 self.hour_rotation = Rotating( clock.hour_hand, radians=hour_radians, **rot_kwargs ) self.hour_rotation.begin() self.minute_rotation = Rotating( clock.minute_hand, radians=12 * hour_radians, **rot_kwargs ) self.minute_rotation.begin() Animation.__init__(self, clock, **kwargs)
def __init__(self, mode="plain", **kwargs): digest_config(self, kwargs) self.mode = mode self.parts_named = False try: svg_file = os.path.join( PI_CREATURE_DIR, "%s_%s.svg" % (self.file_name_prefix, mode) ) SVGMobject.__init__(self, file_name=svg_file, **kwargs) except Exception: warnings.warn("No %s design with mode %s" % (self.file_name_prefix, mode)) svg_file = os.path.join( FILE_DIR, "PiCreatures_plain.svg", ) SVGMobject.__init__(self, mode="plain", file_name=svg_file, **kwargs) if self.flip_at_start: self.flip() if self.start_corner is not None: self.to_corner(self.start_corner)
def __init__(self, **kwargs): digest_config(self, kwargs)
def __init__(self, mobject, update_function, **kwargs): digest_config(self, kwargs, locals()) OldAnimation.__init__(self, mobject, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) self.x_range = np.array(self.default_x_range) self.y_range = np.array(self.default_y_range)
def __init__(self, start=LEFT, end=RIGHT, **kwargs): digest_config(self, kwargs) self.set_start_and_end_attrs(start, end) VMobject.__init__(self, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) self.epsilon = 1.0 / self.density Mobject.__init__(self, **kwargs)
def __init__(self, *points, **kwargs): digest_config(self, kwargs) self.net = ConstructNet(list(points)) self.kwargs = kwargs VGroup.__init__(self, *[Line(*each, **kwargs) for each in self.VisitNet()])
def __init__(self, ct_or_hexagon, **kwargs): digest_config(self, kwargs, locals()) self.mob_type = "ct" if isinstance(ct_or_hexagon, CalissonTiling3D) else "hexagon" VMobject.__init__(self, **kwargs)
def __init__(self, **kwargs): # print('\n',kwargs,len(kwargs)) # print(self.__class__) digest_config(self, kwargs)
def __init__(self, scene, **kwargs): digest_config(self, kwargs) self.scene = scene self.writing_process = None self.init_output_directories() self.init_audio()
def __init__(self, mobject, **kwargs): assert (isinstance(mobject, Mobject)) digest_config(self, kwargs) self.mobject = mobject
def __init__(self, **kwargs): digest_config(self, kwargs) TexMobject.__init__(self, self.tex, **kwargs) self.set_color(self.color)
def __init__(self, start=LEFT, end=RIGHT, **kwargs): digest_config(self, kwargs) self.set_start_and_end_attrs(start, end) VMobject.__init__(self, **kwargs)
def __init__(self, *continual_animations, **kwargs): digest_config(self, kwargs, locals()) self.group = Group(*[ca.mobject for ca in continual_animations]) ContinualAnimation.__init__(self, self.group, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) TexMobject.__init__(self, self.tex, **kwargs) self.set_color(self.color)
def __init__(self, n=3, **kwargs): digest_config(self, kwargs, locals()) start_vect = rotate_vector(RIGHT, self.start_angle) vertices = compass_directions(n, start_vect) Polygon.__init__(self, *vertices, **kwargs)
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) kwargs["width"] = mobject.get_width() + 2 * self.buff kwargs["height"] = mobject.get_height() + 2 * self.buff Rectangle.__init__(self, **kwargs) self.move_to(mobject)
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) circle = self.get_circle(mobject) super().__init__(circle, **kwargs)
def __init__(self, file_name=None, **kwargs): digest_config(self, kwargs) self.file_name = file_name or self.file_name self.ensure_valid_file() VMobject.__init__(self, **kwargs) self.move_into_position()
def update_config(self, **kwargs): digest_config(self, kwargs) return self
def __init__(self, x_range=None, y_range=None, **kwargs): digest_config(self, kwargs) kwargs["number_line_config"] = self.axis_config Axes.__init__(self, x_range, y_range, **kwargs) self.init_vars() self.init_background_lines()
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) target = mobject.copy() target.scale_in_place(self.scale_factor) target.set_color(self.color) OldTransform.__init__(self, mobject, target, **kwargs)
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) kwargs["width"] = mobject.get_width() + 2 * self.buff kwargs["height"] = mobject.get_height() + 2 * self.buff Rectangle.__init__(self, **kwargs) self.move_to(mobject)
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) circle = Circle(color=self.color, **kwargs) circle.surround(mobject) OldIndicate.__init__(self, circle, **kwargs)
def __init__(self, rows, columns, **kwargs): digest_config(self, kwargs, locals()) VMobject.__init__(self, **kwargs)
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) self.set_default_config_from_length(mobject) super().__init__(mobject, **kwargs)
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) self.set_default_config_from_length(mobject) super().__init__(mobject, **kwargs)
def __init__(self, mobject, tracked_mobject, **kwargs): digest_config(self, kwargs, locals()) tcp = self.tracked_critical_point self.diff = mobject.get_critical_point(tcp) - \ tracked_mobject.get_critical_point(tcp) OldAnimation.__init__(self, mobject, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) kwargs["number_line_config"] = self.axis_config Axes.__init__(self, **kwargs) self.init_background_lines()
def __init__(self, t_func, **kwargs): digest_config(self, kwargs) self.t_range = [self.t_min, self.t_max, self.get_step_size()] ParametricCurve.__init__(self, t_func, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) Rectangle.__init__(self, height=self.side_length, width=self.side_length, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) Rectangle.__init__(self, width=self.aspect_ratio * self.height, height=self.height, **kwargs)
def __init__(self, source_mobject: MTex, target_mobject: MTex, **kwargs): digest_config(self, kwargs) assert isinstance(source_mobject, MTex) assert isinstance(target_mobject, MTex) anims = [] rest_source_submobs = source_mobject.submobjects.copy() rest_target_submobs = target_mobject.submobjects.copy() def add_anim_from(anim_class, func, source_attr, target_attr=None): if target_attr is None: target_attr = source_attr source_parts = func(source_mobject, source_attr) target_parts = func(target_mobject, target_attr) filtered_source_parts = [ submob_part for submob_part in source_parts if all([ submob in rest_source_submobs for submob in submob_part ]) ] filtered_target_parts = [ submob_part for submob_part in target_parts if all([ submob in rest_target_submobs for submob in submob_part ]) ] if not (filtered_source_parts and filtered_target_parts): return anims.append(anim_class( VGroup(*filtered_source_parts), VGroup(*filtered_target_parts), **kwargs )) for submob in it.chain(*filtered_source_parts): rest_source_submobs.remove(submob) for submob in it.chain(*filtered_target_parts): rest_target_submobs.remove(submob) def get_submobs_from_keys(mobject, keys): if not isinstance(keys, tuple): keys = (keys,) indices = [] for key in keys: if isinstance(key, int): indices.append(key) elif isinstance(key, range): indices.extend(key) elif isinstance(key, str): all_parts = mobject.get_parts_by_tex(key) indices.extend(it.chain(*[ mobject.indices_of_part(part) for part in all_parts ])) else: raise TypeError(key) return VGroup(VGroup(*[ mobject[i] for i in remove_list_redundancies(indices) ])) for source_key, target_key in self.key_map.items(): add_anim_from( ReplacementTransform, get_submobs_from_keys, source_key, target_key ) common_specified_substrings = sorted(list( set(source_mobject.get_specified_substrings()).intersection( target_mobject.get_specified_substrings() ) ), key=len, reverse=True) for part_tex_string in common_specified_substrings: add_anim_from( FadeTransformPieces, MTex.get_parts_by_tex, part_tex_string ) common_submob_tex_strings = { source_submob.get_tex() for source_submob in source_mobject }.intersection({ target_submob.get_tex() for target_submob in target_mobject }) for tex_string in common_submob_tex_strings: add_anim_from( FadeTransformPieces, lambda mobject, attr: VGroup(*[ VGroup(mob) for mob in mobject if mob.get_tex() == attr ]), tex_string ) anims.append(FadeOutToPoint( VGroup(*rest_source_submobs), target_mobject.get_center(), **kwargs )) anims.append(FadeInFromPoint( VGroup(*rest_target_submobs), source_mobject.get_center(), **kwargs )) super().__init__(*anims)
def __init__(self, scene, **kwargs): digest_config(self, kwargs) self.scene = scene self.stream_lock = False self.init_output_directories() self.init_audio()
def __init__(self, start, end, **kwargs): digest_config(self, kwargs) self.set_start_and_end(start, end) VMobject.__init__(self, **kwargs)
def __init__(self, scene, **kwargs): digest_config(self, kwargs) self.scene = scene self.stream_lock = False self.init_output_directories() self.init_audio()
def __init__(self, **kwargs): digest_config(self, kwargs) self.scale_factor = 2 * (1 + np.cos(self.angle)) LindenmayerCurve.__init__(self, **kwargs)