def __init__(self, **kwargs): digest_config(self, kwargs) if self.leftmost_tick is None: self.leftmost_tick = np.ceil(self.x_min) VMobject.__init__(self, **kwargs) if self.include_tip: self.add_tip()
def __init__(self, **kwargs): hand = SVGMobject("RightHandOutline") self.inlines = VMobject(*hand.split()[:-4]) self.outline = VMobject(*hand.split()[-4:]) self.outline.set_stroke(color = WHITE, width = 5) self.inlines.set_stroke(color = DARK_GREY, width = 3) VMobject.__init__(self, self.outline, self.inlines) self.center().scale_to_fit_height(3)
def __init__(self, **kwargs): digest_config(self, kwargs) if self.leftmost_tick is None: tf = self.tick_frequency self.leftmost_tick = tf*np.ceil(self.x_min/tf) VMobject.__init__(self, **kwargs) if self.include_tip: self.add_tip()
def __init__(self, **kwargs): hand = SVGMobject("RightHandOutline") self.inlines = VMobject(*hand.split()[:-4]) self.outline = VMobject(*hand.split()[-4:]) self.outline.set_stroke(color=WHITE, width=5) self.inlines.set_stroke(color=DARK_GREY, width=3) VMobject.__init__(self, self.outline, self.inlines) self.center().scale_to_fit_height(3)
def __init__(self, number, **kwargs): digest_config(self, kwargs, locals()) num_string = '%.*f' % (self.num_decimal_points, number) VMobject.__init__(self, *[TexMobject(char) for char in num_string], **kwargs) self.arrange_submobjects(buff=self.digit_to_digit_buff, aligned_edge=DOWN) if number < 0: minus = self.submobjects[0] minus.next_to(self.submobjects[1], LEFT, buff=self.digit_to_digit_buff)
def __init__(self, mob, **kwargs): digest_locals(self) VMobject.__init__(self, **kwargs) buff = float(self.spacing) / self.dashes_num for i in range(self.dashes_num): a = ((1 + buff) * i) / self.dashes_num b = 1 - ((1 + buff) * (self.dashes_num - 1 - i)) / self.dashes_num dash = VMobject(color=self.color) dash.pointwise_become_partial(mob, a, b) self.submobjects.append(dash)
def __init__(self, mob, **kwargs): digest_locals(self) VMobject.__init__(self, **kwargs) segment_len = (1 - float(self.spacing)) / self.dashes_num for i in range(self.dashes_num): a = float(i) / self.dashes_num b = a + segment_len dash = VMobject(color=self.color) dash.pointwise_become_partial(mob, a, b) self.submobjects.append(dash)
def __init__(self, obj, text, brace_direction = DOWN, **kwargs): VMobject.__init__(self, **kwargs) self.brace_direction = brace_direction if isinstance(obj, list): obj = VMobject(*obj) self.brace = Brace(obj, brace_direction, **kwargs) if isinstance(text, tuple) or isinstance(text, list): self.label = self.label_constructor(*text, **kwargs) else: self.label = self.label_constructor(str(text)) if self.label_scale != 1: self.label.scale(self.label_scale) self.brace.put_at_tip(self.label) self.submobjects = [self.brace, self.label]
def __init__(self, number, **kwargs): VMobject.__init__(self, **kwargs) self.number = number ndp = self.num_decimal_points #Build number string if isinstance(number, complex): num_string = '%.*f%s%.*fi'%( ndp, number.real, "-" if number.imag < 0 else "+", ndp, abs(number.imag) ) else: num_string = '%.*f'%(ndp, number) negative_zero_string = "-%.*f"%(ndp, 0.) if num_string == negative_zero_string: num_string = num_string[1:] self.add(*[ TexMobject(char, **kwargs) for char in num_string ]) #Add non-numerical bits if self.show_ellipsis: self.add(TexMobject("\\dots")) if self.unit is not None: self.add(TexMobject(self.unit)) self.arrange_submobjects( buff = self.digit_to_digit_buff, aligned_edge = DOWN ) #Handle alignment of parts that should be aligned #to the bottom for i, c in enumerate(num_string): if c == "-" and len(num_string) > i+1: self[i].align_to(self[i+1], alignment_vect = UP) if self.unit == "\\circ": self[-1].align_to(self, UP) # if self.include_background_rectangle: #TODO, is this the best way to handle #background rectangles? self.background_rectangle = BackgroundRectangle(self) self.submobjects = [ self.background_rectangle, VGroup(*self.submobjects) ]
def __init__(self, camera): VMobject.__init__(self) stroke = 20 factor = sum(PRODUCTION_QUALITY_CAMERA_CONFIG["pixel_shape"]) / sum( camera.pixel_shape) stroke /= factor self.add(Circle()) h1, h2, x = 1, 1.5, 0.5 y = -np.sqrt(1 - x**2) + h1 self.add(Line([-x, y, 0], [-x, y - h1, 0])) self.add(Line([0, 1, 0], [0, 1 - h2, 0])) self.add(Line([x, y, 0], [x, y - h1, 0])) self.set_stroke(color="#00ffff", width=stroke) self.to_corner(RIGHT + DOWN)
def __init__(self, matrix, **kwargs): """ Matrix can either either include numbres, tex_strings, or mobjects """ VMobject.__init__(self, **kwargs) matrix = np.array(matrix) if matrix.ndim == 1: matrix = matrix.reshape((matrix.size, 1)) if not isinstance(matrix[0][0], Mobject): matrix = matrix.astype("string") matrix = self.string_matrix_to_mob_matrix(matrix) self.organize_mob_matrix(matrix) self.add(*matrix.flatten()) self.add_brackets() self.center() self.mob_matrix = matrix
def __init__(self, float_num, **kwargs): digest_config(self, kwargs) num_string = '%.*f' % (self.num_decimal_points, float_num) VMobject.__init__(self, *[ TexMobject(char) for char in num_string ], **kwargs) self.arrange_submobjects( buff = self.digit_to_digit_buff, aligned_edge = DOWN ) if float_num < 0: minus = self.submobjects[0] minus.next_to( self.submobjects[1], LEFT, buff = self.digit_to_digit_buff )
def __init__(self, number, **kwargs): VMobject.__init__(self, **kwargs) self.number = number ndp = self.num_decimal_points #Build number string if isinstance(number, complex): num_string = '%.*f%s%.*fi' % (ndp, number.real, "-" if number.imag < 0 else "+", ndp, abs(number.imag)) else: num_string = '%.*f' % (ndp, number) negative_zero_string = "-%.*f" % (ndp, 0.) if num_string == negative_zero_string: num_string = num_string[1:] self.add(*[TexMobject(char, **kwargs) for char in num_string]) #Add non-numerical bits if self.show_ellipsis: self.add(TexMobject("\\dots")) if num_string.startswith("-"): minus = self.submobjects[0] minus.next_to(self.submobjects[1], LEFT, buff=self.digit_to_digit_buff) if self.unit != None: self.unit_sign = TexMobject(self.unit) self.add(self.unit_sign) self.arrange_submobjects(buff=self.digit_to_digit_buff, aligned_edge=DOWN) #Handle alignment of parts that should be aligned #to the bottom for i, c in enumerate(num_string): if c == "-" and len(num_string) > i + 1: self[i].align_to(self[i + 1], alignment_vect=UP) if self.unit and self.unit.startswith("^"): self.unit_sign.align_to(self, UP) # if self.include_background_rectangle: self.add_background_rectangle()
def __init__(self, matrix, **kwargs): """ Matrix can either either include numbres, tex_strings, or mobjects """ VMobject.__init__(self, **kwargs) matrix = np.array(matrix) if matrix.ndim == 1: matrix = matrix.reshape((matrix.size, 1)) if not isinstance(matrix[0][0], Mobject): matrix = matrix.astype("string") matrix = self.string_matrix_to_mob_matrix(matrix) self.organize_mob_matrix(matrix) self.add(*matrix.flatten()) self.add_brackets() self.center() self.mob_matrix = matrix if self.add_background_rectangles: for mob in matrix.flatten(): mob.add_background_rectangle()
def __init__(self, mobject, **kwargs): VMobject.__init__(self, **kwargs) self.mobject = mobject self.submobjects = self.get_eyes().submobjects
def __init__(self, function, **kwargs): self.function = function VMobject.__init__(self, **kwargs)
def __init__(self, points, **kwargs): VMobject.__init__(self, **kwargs) self.set_points(points)
def __init__(self, start, end, **kwargs): digest_config(self, kwargs) self.set_start_and_end(start, end) VMobject.__init__(self, **kwargs)
def __init__(self, *vertices, **kwargs): assert len(vertices) > 1 digest_locals(self) VMobject.__init__(self, **kwargs)
def __init__(self, angle, **kwargs): self.angle = angle VMobject.__init__(self, **kwargs)
def __init__(self, **kwargs): VMobject.__init__(self, **kwargs) for submobject in self.submobject_family(): submobject.part_of_three_d_mobject = True
def __init__(self, rows, columns, **kwargs): digest_config(self, kwargs, locals()) VMobject.__init__(self, **kwargs)
def __init__(self, angle, **kwargs): digest_locals(self) VMobject.__init__(self, **kwargs)
def __init__(self, **kwargs): digest_config(self, kwargs) if self.leftmost_tick is None: self.leftmost_tick = np.ceil(self.x_min) VMobject.__init__(self, **kwargs)
def __init__(self, **kwargs): VMobject.__init__(self, **kwargs) for submobject in self.submobject_family(): submobject.part_of_3d_mobject = True
def __init__(self, *args, **kwargs): VMobject.__init__(self, *args, **kwargs) shade_in_3d(self)