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, 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) videos = [VideoIcon() for x in range(self.num_videos)] VGroup.__init__(self, *videos, **kwargs) self.arrange_submobjects() self.set_width(FRAME_WIDTH - MED_LARGE_BUFF) self.set_color_by_gradient(*self.gradient_colors)
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) if self.scale_about_point is None: self.scale_about_point = mobject.get_center() if self.rotate_about_point is None: self.rotate_about_point = mobject.get_center() Animation.__init__(self, mobject, **kwargs)
def __init__(self, mobject, **kwargs): mobject = instantiate(mobject) assert (isinstance(mobject, Mobject)) digest_config(self, kwargs, locals()) self.internal_time = 0 self.external_time = 0 self.setup() self.update(0)
def __init__(self, mobject, direction=None, **kwargs): digest_config(self, kwargs) target = mobject.copy() if direction is None: direction = self.direction mobject.shift(direction) mobject.fade(1) Transform.__init__(self, mobject, target, **kwargs)
def __init__(self, mobject, point, **kwargs): digest_config(self, kwargs) target = mobject.copy() point_mob = VectorizedPoint(point) if self.point_color: point_mob.set_color(self.point_color) mobject.replace(point_mob) mobject.set_color(point_mob.get_color()) Transform.__init__(self, mobject, target, **kwargs)
def __init__(self, homotopy, mobject, **kwargs): """ Homotopy a function from (x, y, z, t) to (x', y', z') """ def function_at_time_t(t): return lambda p: homotopy(p[0], p[1], p[2], t) self.function_at_time_t = function_at_time_t digest_config(self, kwargs) Animation.__init__(self, mobject, **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, mobject, target_mobject, **kwargs): # Copy target_mobject so as to not mess with caller self.original_target_mobject = target_mobject target_mobject = target_mobject.copy() mobject.align_data(target_mobject) self.target_mobject = target_mobject digest_config(self, kwargs) self.init_path_func() Animation.__init__(self, mobject, **kwargs) self.name += "To" + str(target_mobject)
def __init__(self, **kwargs): digest_config(self, kwargs) kwargs.update({ "x_unit_size": self.unit_size, "y_unit_size": self.unit_size, "x_line_frequency": self.line_frequency, "x_faded_line_frequency": self.faded_line_frequency, "y_line_frequency": self.line_frequency, "y_faded_line_frequency": self.faded_line_frequency, }) NumberPlane.__init__(self, **kwargs)
def __init__(self, mobject, **kwargs): mobject = instantiate(mobject) assert(isinstance(mobject, Mobject)) digest_config(self, kwargs, locals()) self.starting_mobject = self.mobject.copy() if self.rate_func is None: self.rate_func = (lambda x: x) if self.name is None: self.name = self.__class__.__name__ + str(self.mobject) self.all_families_zipped = self.get_all_families_zipped() self.update(0)
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, 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, 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.minute_rotation = Rotating(clock.minute_hand, radians=12 * hour_radians, **rot_kwargs) Animation.__init__(self, clock, **kwargs)
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, **kwargs): digest_config(self, kwargs) height = self.height if "height" in kwargs: kwargs.pop("height") Rectangle.__init__( self, width=self.aspect_ratio[0], height=self.aspect_ratio[1], **kwargs ) self.set_height(height)
def __init__(self, function, **kwargs): digest_config(self, kwargs) def parametric_function(t): return t * RIGHT + function(t) * UP ParametricFunction.__init__(self, parametric_function, t_min=self.x_min, t_max=self.x_max, **kwargs) self.function = function
def __init__(self, *sub_anims, **kwargs): sub_anims = [x for x in sub_anims if not (x.empty)] digest_config(self, locals()) self.update_config(**kwargs) # Handles propagation to self.sub_anims if len(sub_anims) == 0: self.empty = True self.run_time = 0 else: self.run_time = max([a.run_time for a in sub_anims]) everything = Mobject(*[a.mobject for a in sub_anims]) Animation.__init__(self, everything, **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, mobject_or_point, **kwargs): digest_config(self, kwargs) big_dot = Dot( radius=FRAME_X_RADIUS + FRAME_Y_RADIUS, stroke_width=0, fill_color=self.color, fill_opacity=0, ) little_dot = Dot(radius=0) little_dot.set_fill(self.color, opacity=self.opacity) little_dot.move_to(mobject_or_point) Transform.__init__(self, big_dot, little_dot, **kwargs)
def __init__(self, mobject, **kwargs): digest_config(self, kwargs, locals()) left_x = mobject.get_left()[0] right_x = mobject.get_right()[0] vect = self.amplitude * self.direction def homotopy(x, y, z, t): alpha = (x - left_x) / (right_x - left_x) # lf = self.lag_factor power = np.exp(2.0 * (alpha - 0.5)) nudge = there_and_back(t**power) return np.array([x, y, z]) + nudge * vect Homotopy.__init__(self, homotopy, mobject, **kwargs)
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, 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, mobject, angle=np.pi, axis=OUT, **kwargs): if "path_arc" not in kwargs: kwargs["path_arc"] = angle if "path_arc_axis" not in kwargs: kwargs["path_arc_axis"] = axis digest_config(self, kwargs, locals()) target = mobject.copy() if self.in_place: self.about_point = mobject.get_center() target.rotate( angle, axis=axis, about_point=self.about_point, ) Transform.__init__(self, mobject, target, **kwargs)
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, mob_or_text, **kwargs): digest_config(self, kwargs) if isinstance(mob_or_text, str): mobject = TextMobject(mob_or_text) else: mobject = mob_or_text if "run_time" not in kwargs: self.establish_run_time(mobject) if "lag_factor" not in kwargs: if len(mobject.family_members_with_points()) < 4: min_lag_factor = 1 else: min_lag_factor = 2 self.lag_factor = max(self.run_time - 1, min_lag_factor) DrawBorderThenFill.__init__(self, mobject, **kwargs)
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, 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, 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)