def __init__(self, point, color=YELLOW, **kwargs): digest_config(self, kwargs) lines = VGroup() for angle in np.arange(0, TAU, TAU / self.num_lines): line = Line(ORIGIN, self.line_length * RIGHT) line.shift((self.flash_radius - self.line_length) * RIGHT) line.rotate(angle, about_point=ORIGIN) lines.add(line) lines.move_to(point) lines.set_color(color) lines.set_stroke(width=3) line_anims = [ ShowCreationThenDestruction( line, rate_func=squish_rate_func(smooth, 0, 0.5) ) for line in lines ] fade_anims = [ UpdateFromAlphaFunc( line, lambda m, a: m.set_stroke( width=self.line_stroke_width * (1 - a) ), rate_func=squish_rate_func(smooth, 0, 0.75) ) for line in lines ] AnimationGroup.__init__( self, *line_anims + fade_anims, **kwargs )
def create_lines(self): lines = VGroup() for angle in np.arange(0, TAU, TAU / self.num_lines): line = Line(ORIGIN, self.line_length * RIGHT) line.shift((self.flash_radius - self.line_length) * RIGHT) line.rotate(angle, about_point=ORIGIN) lines.add(line) lines.set_color(self.color) lines.set_stroke(width=3) lines.add_updater(lambda l: l.move_to(self.point)) return lines
def gen_text_backgrounds(self, text): text_with_visible_chars = text.replace(" ", "").replace('\t', "") text_list = text_with_visible_chars.split("\n") text_backgrounds = VGroup() start_i = 0 for line_no in range(text_list.__len__()): rect_counts = len(text_list[line_no]) text_backgrounds.add(*self[start_i:rect_counts]) start_i += 2 * rect_counts text_backgrounds.set_color(self.background_color) return text_backgrounds
def add_remark(self): nl_text = TextMobject("数轴") nl_arrow = Arrow(ORIGIN, UP).match_height(nl_text) nl_remark = VGroup(nl_arrow, nl_text) nl_remark.scale(0.8) nl_remark.set_color(LIGHT_GREY) nl_remark.arrange_submobjects(RIGHT, buff = 0.1) nl_remark.next_to(self.axes.coords_to_point(0, 0), DOWN, buff = 0.1) nl_remark.to_edge(LEFT, buff = 0.15) frac_remark = TextMobject("圆内分数为圆心横坐标") frac_remark.scale(0.6) frac_remark.to_corner(DL, buff = 0.15) farey_sum_remark = TexMobject( "\\text{Farey Sum: }", "\\dfrac{a}{b} \\oplus \\dfrac{c}{d}", "=", "\\dfrac{a+c}{b+d}" ) farey_sum_remark[1].set_color(YELLOW) farey_sum_remark[-1].set_color(PINK) farey_sum_remark.to_corner(DR, buff = 0.15) self.add(nl_remark, frac_remark, farey_sum_remark)