def __init__(self, **kwargs): x_axis = NumberLine(**kwargs) y_axis = NumberLine(**kwargs).rotate(np.pi/2, OUT) Mobject.__init__(self, x_axis, y_axis)
def __init__(self, **kwargs): Mobject.__init__(self, **kwargs) for part_name in self.PART_NAMES: mob = ImageMobject( part_name_to_directory(part_name), should_center = False ) if part_name not in self.WHITE_PART_NAMES: mob.highlight(self.color) setattr(self, part_name, mob) self.eyes = Mobject(self.left_eye, self.right_eye) self.legs = Mobject(self.left_leg, self.right_leg) mouth_center = self.get_mouth_center() self.mouth.center() self.smile = self.mouth self.frown = self.mouth.copy().rotate(np.pi, RIGHT) self.straight_mouth = TexMobject("-").scale(0.7) for mouth in self.smile, self.frown, self.straight_mouth: mouth.sort_points(lambda p : p[0]) mouth.highlight(self.color) ##to blend into background mouth.shift(mouth_center) self.digest_mobject_attrs() self.give_smile() self.add(self.mouth) self.scale(PI_CREATURE_SCALE_VAL)
def __init__(self, *args, **kwargs): Mobject.__init__(self, *args, **kwargs) complex_power = 0.9 radius = self.INITIAL_WIDTH/2 circle = Circle(density = radius*DEFAULT_POINT_DENSITY_1D) circle.apply_complex_function(lambda z : z**complex_power) circle.scale(radius) boundary_point_as_complex = radius*complex(-1)**complex_power boundary_points = [ [ boundary_point_as_complex.real, unit*boundary_point_as_complex.imag, 0 ] for unit in -1, 1 ] tip = radius*(1.5*LEFT+UP) self.add( circle, Line(boundary_points[0], tip), Line(boundary_points[1], tip) ) self.highlight("white") self.rotate(np.pi/2) self.points[:,1] *= float(self.INITIAL_HEIGHT)/self.INITIAL_WIDTH Bubble.__init__(self, direction = LEFT)
def __init__(self, filename_or_array, **kwargs): if isinstance(filename_or_array, str): path = get_full_image_path(filename_or_array) image = Image.open(path).convert("RGB") self.pixel_array = np.array(image) else: self.pixel_array = np.array(filename_or_array) Mobject.__init__(self, **kwargs)
def __init__(self, expression, **kwargs): if "size" not in kwargs: #Todo, make this more sophisticated. if len("".join(expression)) < MAX_LEN_FOR_HUGE_TEX_FONT: size = "\\Huge" else: size = "\\large" digest_locals(self) Mobject.__init__(self, **kwargs)
def __init__(self, function, **kwargs): self.function = function if self.density: self.epsilon = 1.0 / self.density elif self.dim == 1: self.epsilon = 1.0 / self.expected_measure / DEFAULT_POINT_DENSITY_1D else: self.epsilon = 1.0 / np.sqrt(self.expected_measure) / DEFAULT_POINT_DENSITY_2D Mobject.__init__(self, **kwargs)
def __init__(self, image_file, **kwargs): digest_locals(self) Mobject.__init__(self, **kwargs) self.name = to_camel_case(os.path.split(image_file)[-1].split(".")[0]) path = get_full_image_path(image_file) self.generate_points_from_file(path) self.scale(self.scale_factorue) if self.should_center: self.center()
def __init__(self, condition = (lambda x, y : True), **kwargs): """ Condition must be a function which takes in two real arrays (representing x and y values of space respectively) and return a boolean array. This can essentially look like a function from R^2 to {True, False}, but & and | must be used in place of "and" and "or" """ Mobject.__init__(self, **kwargs) self.condition = condition
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() Mobject.__init__(self, **kwargs)
def __init__(self, light_source=ORIGIN, screen=None, light_cone=None): Mobject.__init__(self) self.light_cone = light_cone self.light_source = light_source self.screen = screen self.light_cone.move_source_to(self.light_source) self.shadow = VMobject(fill_color=BLACK, stroke_width=0, fill_opacity=1.0) self.add(self.light_cone, self.screen, self.shadow) self.update_shadow(self.shadow)
def __init__(self, image_file, **kwargs): digest_locals(self) Mobject.__init__(self, **kwargs) self.name = to_camel_case( os.path.split(image_file)[-1].split(".")[0] ) path = get_full_image_path(image_file) self.generate_points_from_file(path) self.scale(self.scale_factorue) if self.should_center: self.center()
def __init__(self, *args, **kwargs): Mobject.__init__(self, *args, **kwargs) self.add(Circle().scale(0.15).shift(2.5 * DOWN + 2 * LEFT)) self.add(Circle().scale(0.3).shift(2 * DOWN + 1.5 * LEFT)) for n in range(self.NUM_BULGES): theta = 2 * np.pi * n / self.NUM_BULGES self.add(Circle().shift((np.cos(theta), np.sin(theta), 0))) self.filter_out( lambda p: np.linalg.norm(p) < self.INITIAL_INNER_RADIUS) self.stretch_to_fit_width(self.INITIAL_WIDTH) self.highlight("white") Bubble.__init__(self, index_of_tip=np.argmin(self.points[:, 1]), **kwargs)
def __init__(self, *args, **kwargs): Mobject.__init__(self, *args, **kwargs) self.add(Circle().scale(0.15).shift(2.5*DOWN+2*LEFT)) self.add(Circle().scale(0.3).shift(2*DOWN+1.5*LEFT)) for n in range(self.NUM_BULGES): theta = 2*np.pi*n/self.NUM_BULGES self.add(Circle().shift((np.cos(theta), np.sin(theta), 0))) self.filter_out(lambda p : np.linalg.norm(p) < self.INITIAL_INNER_RADIUS) self.stretch_to_fit_width(self.INITIAL_WIDTH) self.highlight("white") Bubble.__init__( self, index_of_tip = np.argmin(self.points[:,1]), **kwargs )
def __init__(self, function, dim = 1, expected_measure = 10.0, density = None, *args, **kwargs): self.function = function self.dim = dim self.expected_measure = expected_measure if density: self.epsilon = 1.0 / density elif self.dim == 1: self.epsilon = 1.0 / expected_measure / DEFAULT_POINT_DENSITY_1D else: self.epsilon = 1.0 / np.sqrt(expected_measure) / DEFAULT_POINT_DENSITY_2D Mobject.__init__(self, *args, **kwargs)
def __init__(self, image_file, **kwargs): digest_locals(self) Mobject.__init__(self, **kwargs) self.name = to_cammel_case(os.path.split(image_file)[-1].split(".")[0]) possible_paths = [ image_file, os.path.join(IMAGE_DIR, image_file), os.path.join(IMAGE_DIR, image_file + ".jpg"), os.path.join(IMAGE_DIR, image_file + ".png"), ] for path in possible_paths: if os.path.exists(path): self.generate_points_from_file(path) self.scale(self.scale_value) if self.should_center: self.center() return raise IOError("File not Found")
def __init__(self, *args, **kwargs): Mobject.__init__(self, *args, **kwargs) complex_power = 0.9 radius = self.INITIAL_WIDTH / 2 circle = Circle(density=radius * DEFAULT_POINT_DENSITY_1D) circle.apply_complex_function(lambda z: z**complex_power) circle.scale(radius) boundary_point_as_complex = radius * complex(-1)**complex_power boundary_points = [[ boundary_point_as_complex.real, unit * boundary_point_as_complex.imag, 0 ] for unit in -1, 1] tip = radius * (1.5 * LEFT + UP) self.add(circle, Line(boundary_points[0], tip), Line(boundary_points[1], tip)) self.highlight("white") self.rotate(np.pi / 2) self.points[:, 1] *= float(self.INITIAL_HEIGHT) / self.INITIAL_WIDTH Bubble.__init__(self, direction=LEFT)
def __init__(self, image_file, **kwargs): digest_locals(self) Mobject.__init__(self, **kwargs) self.name = to_cammel_case( os.path.split(image_file)[-1].split(".")[0] ) possible_paths = [ image_file, os.path.join(IMAGE_DIR, image_file), os.path.join(IMAGE_DIR, image_file + ".jpg"), os.path.join(IMAGE_DIR, image_file + ".png"), ] for path in possible_paths: if os.path.exists(path): self.generate_points_from_file(path) self.scale(self.scale_value) if self.should_center: self.center() return raise IOError("File not Found")
def __init__(self, **kwargs): Mobject.__init__(self, **kwargs) for part_name in self.PART_NAMES: mob = ImageMobject(part_name_to_directory(part_name), should_center=False) if part_name not in self.WHITE_PART_NAMES: mob.highlight(self.color) setattr(self, part_name, mob) self.eyes = Mobject(self.left_eye, self.right_eye) self.legs = Mobject(self.left_leg, self.right_leg) mouth_center = self.get_mouth_center() self.mouth.center() self.smile = self.mouth self.frown = self.mouth.copy().rotate(np.pi, RIGHT) self.straight_mouth = TexMobject("-").scale(0.7) for mouth in self.smile, self.frown, self.straight_mouth: mouth.sort_points(lambda p: p[0]) mouth.highlight(self.color) ##to blend into background mouth.shift(mouth_center) self.digest_mobject_attrs() self.give_smile() self.add(self.mouth) self.scale(PI_CREATURE_SCALE_VAL)
def __init__(self, **kwargs): Mobject.__init__(self, **kwargs) self.center_offset = self.center_point - Mobject.get_center(self) if self.direction[0] > 0: self.rotate(np.pi, UP) self.content = Mobject()
def __init__(self, location = ORIGIN, **kwargs): digest_locals(self) Mobject.__init__(self, **kwargs)
def __init__(self, point = (0, 0, 0), *args, **kwargs): Mobject.__init__(self, *args, **kwargs) self.points = np.array(point).reshape(1, 3) self.rgbs = np.array(self.color.get_rgb()).reshape(1, 3)
def __init__(self, **kwargs): digest_config(self, Stars, kwargs) Mobject.__init__(self, **kwargs)
def to_symbol(self): Mobject.__init__( self, *list(set(self.get_parts()).difference(self.get_white_parts())) )
def __init__(self, num_points=DEFAULT_NUM_STARS, *args, **kwargs): self.num_points = num_points Mobject.__init__(self, *args, **kwargs)
def __init__(self, image_array, **kwargs): Mobject.__init__(self, **kwargs) self.generate_points_from_image_array(image_array)
def to_symbol(self): Mobject.__init__( self, *list(set(self.get_parts()).difference(self.get_white_parts())))
def __init__(self, **kwargs): x_axis = NumberLine(**kwargs) y_axis = NumberLine(**kwargs).rotate(np.pi / 2, OUT) Mobject.__init__(self, x_axis, y_axis)
def __init__(self, point=(0, 0, 0), *args, **kwargs): Mobject.__init__(self, *args, **kwargs) self.points = np.array(point).reshape(1, 3) self.rgbs = np.array(self.color.get_rgb()).reshape(1, 3)
def __init__(self, num_points = DEFAULT_NUM_STARS, *args, **kwargs): self.num_points = num_points Mobject.__init__(self, *args, **kwargs)