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(consts.FRAME_WIDTH - consts.MED_LARGE_BUFF) self.set_color_by_gradient(*self.gradient_colors)
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, text_mobject, **kwargs): digest_config(self, kwargs) tpc = self.time_per_char anims = it.chain(*[[ ShowIncreasingSubsets(word, run_time=tpc * len(word)), Animation(word, run_time=0.005 * len(word)**1.5), ] for word in text_mobject]) super().__init__(*anims, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) if self.camera_config["pixel_width"] == consts.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, *animations, **kwargs): digest_config(self, kwargs) self.animations = animations if self.group is None: self.group = Group(*remove_list_redundancies( [anim.mobject for anim in animations])) self.init_run_time() Animation.__init__(self, self.group, **kwargs)
def __init__(self, vmob, alpha, **kwargs): digest_config(self, kwargs) da = self.d_alpha a1 = np.clip(alpha - da, 0, 1) a2 = np.clip(alpha + da, 0, 1) super().__init__(vmob.point_from_proportion(a1), vmob.point_from_proportion(a2), **kwargs) self.scale(self.length / self.get_length())
def __init__(self, scene, **kwargs): digest_config(self, kwargs) self.scene = scene self.loop_run = True # For livestreaming, if we don't stop idle stream updating, # it could conflict with animation to cause flashing self.stop_update = False self.init_output_directories() self.init_audio()
def __init__(self, function, **kwargs): digest_config(self, kwargs) self.parametric_function = \ lambda t: np.array([t, function(t), 0]) ParametricFunction.__init__(self, self.parametric_function, t_min=self.x_min, t_max=self.x_max, **kwargs) self.function = function
def __init__(self, mobject, **kwargs): digest_config(self, kwargs) if "surrounding_rectangle_config" in kwargs: kwargs.pop("surrounding_rectangle_config") self.mobject_to_surround = mobject rect = self.get_rect() rect.add_updater(lambda r: r.move_to(mobject)) super().__init__(self.rect_animation(rect, **kwargs), )
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 * consts.DEGREES start_vect = rotate_vector(consts.RIGHT, self.start_angle) vertices = compass_directions(n, start_vect) Polygon.__init__(self, *vertices, **kwargs)
def __init__(self, point, color=Color('YELLOW'), **kwargs): self.point = point self.color = color digest_config(self, kwargs) self.lines = self.create_lines() animations = self.create_line_anims() super().__init__( *animations, group=self.lines, **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, 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, 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, consts.DOWN) self.shift(consts.DOWN * eyes.get_height() / 4)
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) power = np.exp(2.0 * (alpha - 0.5)) nudge = there_and_back(t**power) return np.array([x, y, z]) + nudge * vect super().__init__(homotopy, mobject, **kwargs)
def __init__(self, tex_string, **kwargs): digest_config(self, kwargs) self.template_tex_file_body = init_tex_template( isinstance(self, TextMobject)) 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, **kwargs): digest_config(self, kwargs) start = self.unit_size * self.x_min * consts.RIGHT end = self.unit_size * self.x_max * consts.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, 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=consts.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, 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, 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(consts.ASSETS_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: self.flip() self.direction_was_specified = ("direction" in kwargs) self.content = 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=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, text, **config): self.text = text self.full2short(config) digest_config(self, config) self.lsh = self.size if self.lsh == -1 else self.lsh file_name = self.text2svg() SVGMobject.__init__(self, file_name, **config) if self.t2c: self.set_color_by_t2c() if self.gradient: self.set_color_by_gradient(*self.gradient) if self.t2g: self.set_color_by_t2g() # anti-aliasing self.scale(0.1)
def __init__(self, mobject, direction=consts.DOWN, **kwargs): digest_config(self, kwargs, locals()) angle = -np.arctan2(*direction[:2]) + np.pi mobject.rotate(-angle, about_point=consts.ORIGIN) left = mobject.get_corner(consts.DOWN + consts.LEFT) right = mobject.get_corner(consts.DOWN + consts.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(consts.UP + consts.LEFT) + self.buff * consts.DOWN) for mob in mobject, self: mob.rotate(angle, about_point=consts.ORIGIN)
def __init__(self, clock, **kwargs): digest_config(self, kwargs) assert(isinstance(clock, Clock)) rot_kwargs = { "axis": consts.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, 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): assert (isinstance(mobject, Mobject)) digest_config(self, kwargs) self.mobject = mobject
def update_config(self, **kwargs): digest_config(self, kwargs) return self
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()