def construct(self): quote = TextMobject("Imagination is more important than knowledge") quote.set_color(RED) quote.to_edge(UP) quote2 = TextMobject( "A person who never made a mistake never tried anything new") quote2.set_color(YELLOW) author = TextMobject("- Albert Einstein") author.scale(0.75) corner = quote.get_corner(DOWN + RIGHT) print("corner", corner) author.next_to(corner, ORIGIN) self.add(quote, author) self.wait(2) self.play( Transform(quote, quote2), ApplyMethod(author.move_to, quote2.get_corner(DOWN + RIGHT) + DOWN + 2 * LEFT)) self.play(ApplyMethod(author.scale, 1.5)) author.match_color(quote2) self.play(FadeOut(quote), FadeOut(author)) self.wait()
def initialize_texts(self): geom_text = TextMobject("一个边长为$n$的正六边形", "和一些边长为1的菱形") eqtri_text = TextMobject("它们都是由若干正三角形组成的") three_types_text = TextMobject("因为朝向不同,菱形被分成三种") try_tiling_text = TextMobject("现在用这些菱形", "镶嵌", "正六边形...") remark = TextMobject("(无间隙且不重叠地覆盖)") claim_text = TextMobject("最终的图案中", "每种菱形的数量一定都是$n^2$") twist_text = TextMobject("改变菱形的摆放方式", "或者改变正六边形的大小", "这个结论依然成立") how_to_prove_text = TextMobject("如何证明?", "") for text in (geom_text, claim_text, twist_text): text.arrange_submobjects(DOWN, aligned_edge=LEFT) try_tiling_text[1].set_color(GREEN) remark.scale(0.5) remark.set_color(GREEN) remark.next_to(try_tiling_text[1], DOWN, buff=0.1) how_to_prove_text.set_color(YELLOW) bg_texts = VGroup( geom_text, eqtri_text, three_types_text, VGroup(try_tiling_text, remark), ) q_texts = VGroup( claim_text, twist_text, ) for texts in (bg_texts, q_texts, how_to_prove_text): texts.arrange_submobjects(DOWN, aligned_edge=LEFT, buff=1) texts.to_corner(LEFT + UP) self.bg_texts = bg_texts self.q_texts = q_texts self.how_to_prove_text = how_to_prove_text
def get_corner_numbers(self, value, symbol): value_mob = TextMobject(value) width = self.get_width() / self.card_width_to_corner_num_width height = self.get_height() / self.card_height_to_corner_num_height value_mob.set_width(width) value_mob.stretch_to_fit_height(height) value_mob.next_to(self.get_corner(UP + LEFT), DOWN + RIGHT, buff=MED_LARGE_BUFF * width) value_mob.set_color(symbol.get_color()) corner_symbol = symbol.copy() corner_symbol.set_width(width) corner_symbol.next_to(value_mob, DOWN, buff=MED_SMALL_BUFF * width) corner_group = VGroup(value_mob, corner_symbol) opposite_corner_group = corner_group.copy() opposite_corner_group.rotate(np.pi, about_point=self.get_center()) return VGroup(corner_group, opposite_corner_group)
def initialize_texts(self): proof_texts = TextMobject("“证明”:", "涂颜色", "+", "换视角") proof_texts.arrange_submobjects(RIGHT) proof_texts.to_corner(LEFT + UP) imagine_3d_text = TextMobject("(想象这是一个三维图案...)") imagine_3d_text.to_corner(RIGHT + UP) imagine_3d_text.set_color(YELLOW) rhombi = VGroup(*[ RhombusType(rhombus_config={"fill_opacity": 1}) for RhombusType in (RRhombus, HRhombus, LRhombus) ]) time_texts = VGroup(*[ TexMobject("\\times", "n^2").scale(1.2).set_color( rhombus.get_fill_color()) for rhombus in rhombi ]) rhombi_and_texts = VGroup(*[ VGroup(rhombus, time_text).arrange_submobjects(RIGHT) for rhombus, time_text in zip(rhombi, time_texts) ]) rhombi_and_texts.arrange_submobjects(RIGHT, buff=2) rhombi_and_texts.to_edge(UP, buff=1.4) equation = TexMobject( *["n^2" if k % 2 == 0 else "=" for k in range(5)]) for text, color in zip(equation[::2], RHOMBI_COLOR_SET): text.set_color(color) qed = FakeQEDSymbol(jagged_percentage=0.1) qed.set_height(equation.get_height()) conclusions = VGroup(equation, qed) conclusions.arrange_submobjects(RIGHT, buff=1) conclusions.to_corner(RIGHT + UP) self.proof_texts = proof_texts self.imagine_3d_text = imagine_3d_text self.rhombi = rhombi self.time_texts = time_texts self.rhombi_and_texts = rhombi_and_texts self.conclusions = conclusions
def get_corner_numbers(self, value, symbol): value_mob = TextMobject(value) width = self.get_width() / self.card_width_to_corner_num_width height = self.get_height() / self.card_height_to_corner_num_height value_mob.set_width(width) value_mob.stretch_to_fit_height(height) value_mob.next_to( self.get_corner(UP + LEFT), DOWN + RIGHT, buff=MED_LARGE_BUFF * width ) value_mob.set_color(symbol.get_color()) corner_symbol = symbol.copy() corner_symbol.set_width(width) corner_symbol.next_to( value_mob, DOWN, buff=MED_SMALL_BUFF * width ) corner_group = VGroup(value_mob, corner_symbol) opposite_corner_group = corner_group.copy() opposite_corner_group.rotate( np.pi, about_point=self.get_center() ) return VGroup(corner_group, opposite_corner_group)
def setup_axes(self, animate=False): """ This method sets up the axes of the graph. Parameters ---------- animate (bool=False) Whether or not to animate the setting up of the Axes. """ # TODO, once eoc is done, refactor this to be less redundant. x_num_range = float(self.x_max - self.x_min) self.space_unit_to_x = self.x_axis_width / x_num_range if self.x_labeled_nums is None: self.x_labeled_nums = [] if self.x_leftmost_tick is None: self.x_leftmost_tick = self.x_min x_axis = NumberLine( x_min=self.x_min, x_max=self.x_max, unit_size=self.space_unit_to_x, tick_frequency=self.x_tick_frequency, leftmost_tick=self.x_leftmost_tick, numbers_with_elongated_ticks=self.x_labeled_nums, color=self.axes_color, # Added this line decimal_number_config={"color": self.label_nums_color}) x_axis.shift(self.graph_origin - x_axis.number_to_point(0)) if len(self.x_labeled_nums) > 0: if self.exclude_zero_label: self.x_labeled_nums = [ x for x in self.x_labeled_nums if x != 0 ] x_axis.add_numbers(*self.x_labeled_nums) if self.x_axis_label: x_label = TextMobject(self.x_axis_label) # Added this line x_label.set_color(self.label_color) x_label.next_to(x_axis.get_tick_marks(), UP + RIGHT, buff=SMALL_BUFF) x_label.shift_onto_screen() x_axis.add(x_label) self.x_axis_label_mob = x_label y_num_range = float(self.y_max - self.y_min) self.space_unit_to_y = self.y_axis_height / y_num_range if self.y_labeled_nums is None: self.y_labeled_nums = [] if self.y_bottom_tick is None: self.y_bottom_tick = self.y_min y_axis = NumberLine( x_min=self.y_min, x_max=self.y_max, unit_size=self.space_unit_to_y, tick_frequency=self.y_tick_frequency, leftmost_tick=self.y_bottom_tick, numbers_with_elongated_ticks=self.y_labeled_nums, color=self.axes_color, line_to_number_vect=LEFT, label_direction=LEFT, # yongze added this line decimal_number_config={"color": self.label_nums_color}, ) y_axis.shift(self.graph_origin - y_axis.number_to_point(0)) y_axis.rotate(np.pi / 2, about_point=y_axis.number_to_point(0)) if len(self.y_labeled_nums) > 0: if self.exclude_zero_label: self.y_labeled_nums = [ y for y in self.y_labeled_nums if y != 0 ] y_axis.add_numbers(*self.y_labeled_nums) if self.y_axis_label: y_label = TextMobject(self.y_axis_label) # yongze Added this line y_label.set_color(self.label_color) y_label.next_to(y_axis.get_corner(UP + RIGHT), UP + RIGHT, buff=SMALL_BUFF) y_label.shift_onto_screen() y_axis.add(y_label) self.y_axis_label_mob = y_label if animate: self.play(Write(VGroup(x_axis, y_axis))) else: self.add(x_axis, y_axis) self.x_axis, self.y_axis = self.axes = VGroup(x_axis, y_axis) self.default_graph_colors = it.cycle(self.default_graph_colors)
def get_author(self, quote): author = TextMobject(self.text_size + " --" + self.author) author.next_to(quote, DOWN, buff=self.author_buff) author.set_color(YELLOW) return author
def scroll_through_patrons(self): logo_box = Square(side_length=2.5) logo_box.to_corner(DOWN + LEFT, buff=MED_LARGE_BUFF) total_width = FRAME_X_RADIUS - logo_box.get_right()[0] black_rect = Rectangle( fill_color=BLACK, fill_opacity=1, stroke_width=3, stroke_color=BLACK, width=FRAME_WIDTH, height=0.6 * FRAME_HEIGHT, ) black_rect.to_edge(UP, buff=0) line = DashedLine(FRAME_X_RADIUS * LEFT, FRAME_X_RADIUS * RIGHT) line.move_to(ORIGIN) thanks = TextMobject(self.thanks_words) thanks.scale(0.9) thanks.next_to(black_rect.get_bottom(), UP, SMALL_BUFF) thanks.set_color(YELLOW) underline = Line(LEFT, RIGHT) underline.match_width(thanks) underline.scale(1.1) underline.next_to(thanks, DOWN, SMALL_BUFF) thanks.add(underline) changed_patron_names = map( self.modify_patron_name, self.specific_patrons, ) patrons = VGroup(*map( TextMobject, changed_patron_names, )) patrons.scale(self.patron_scale_val) for patron in patrons: if patron.get_width() > self.max_patron_width: patron.set_width(self.max_patron_width) columns = VGroup(*[ VGroup(*patrons[i::self.n_patron_columns]) for i in range(self.n_patron_columns) ]) for column in columns: for n, name in enumerate(column): name.shift(n * self.name_y_spacing * DOWN) columns.arrange( RIGHT, buff=LARGE_BUFF, aligned_edge=UP, ) max_width = FRAME_WIDTH - 1 if columns.get_width() > max_width: columns.set_width(max_width) underline.match_width(columns) # thanks.to_edge(RIGHT, buff=MED_SMALL_BUFF) columns.next_to(underline, DOWN, buff=2) columns.generate_target() columns.target.to_edge(DOWN, buff=2) vect = columns.target.get_center() - columns.get_center() distance = get_norm(vect) wait_time = 20 always_shift( columns, direction=normalize(vect), rate=(distance / wait_time) ) self.add(columns, black_rect, line, thanks) self.wait(wait_time)
def construct(self): # Add title title = self.title = TextMobject("Clicky Stuffs") title.scale(1.5) title.to_edge(UP, buff=MED_SMALL_BUFF) pi_creatures = VGroup(Randolph(), Mortimer()) for pi, vect in zip(pi_creatures, [LEFT, RIGHT]): pi.set_height(title.get_height()) pi.change_mode("thinking") pi.look(DOWN) pi.next_to(title, vect, buff=MED_LARGE_BUFF) self.add(title, pi_creatures) # Set the top of the screen logo_box = Square(side_length=2.5) logo_box.to_corner(DOWN + LEFT, buff=MED_LARGE_BUFF) black_rect = Rectangle( fill_color=BLACK, fill_opacity=1, stroke_width=3, stroke_color=BLACK, width=FRAME_WIDTH, height=0.6 * FRAME_HEIGHT, ) black_rect.to_edge(UP, buff=0) line = DashedLine(FRAME_X_RADIUS * LEFT, FRAME_X_RADIUS * RIGHT) line.move_to(ORIGIN) # Add thanks thanks = TextMobject(self.thanks_words) thanks.scale(0.9) thanks.next_to(black_rect.get_bottom(), UP, SMALL_BUFF) thanks.set_color(YELLOW) underline = Line(LEFT, RIGHT) underline.match_width(thanks) underline.scale(1.1) underline.next_to(thanks, DOWN, SMALL_BUFF) thanks.add(underline) # Build name list file_name = os.path.join(get_directories()["data"], "patrons.txt") with open(file_name, "r") as fp: names = [ self.modify_patron_name(name.strip()) for name in fp.readlines() ] if self.randomize_order: random.shuffle(names) else: names.sort() name_labels = VGroup(*map(TextMobject, names)) name_labels.scale(self.patron_scale_val) for label in name_labels: if label.get_width() > self.max_patron_width: label.set_width(self.max_patron_width) columns = VGroup(*[ VGroup(*name_labels[i::self.n_patron_columns]) for i in range(self.n_patron_columns) ]) column_x_spacing = 0.5 + max([c.get_width() for c in columns]) for i, column in enumerate(columns): for n, name in enumerate(column): name.shift(n * self.name_y_spacing * DOWN) name.align_to(ORIGIN, LEFT) column.move_to(i * column_x_spacing * RIGHT, UL) columns.center() max_width = FRAME_WIDTH - 1 if columns.get_width() > max_width: columns.set_width(max_width) underline.match_width(columns) columns.next_to(underline, DOWN, buff=3) # Set movement columns.generate_target() distance = columns.get_height() + 2 wait_time = self.scroll_time frame = self.camera.frame frame_shift = ApplyMethod( frame.shift, distance * DOWN, run_time=wait_time, rate_func=linear, ) blink_anims = [] blank_mob = Mobject() for x in range(wait_time): if random.random() < 0.25: blink_anims.append(Blink(random.choice(pi_creatures))) else: blink_anims.append(Animation(blank_mob)) blinks = Succession(*blink_anims) static_group = VGroup(black_rect, line, thanks, pi_creatures, title) static_group.fix_in_frame() self.add(columns, static_group) self.play(frame_shift, blinks)
def construct(self): self._main_title() text_one = TextMobject("Given a list of items sold") text_two: TextMobject = TextMobject( "Randomly choose items matching this distribution") text_two.next_to(text_one, DOWN) number_line = NumberLine( numbers_with_elongated_ticks=[0, 1], include_numbers=True, x_min=0, x_max=1, unit_size=10, tick_frequency=0.1, # decimal_number_config={"num_decimal_places": 1}, numbers_to_show=[0, 1]) number_line.next_to(text_two, UP) self.play(ShowCreation(text_one)) self.wait() self.play(ShowCreation(text_two)) self.wait(4) apples_text = TextMobject("Apples:") apples_text.set_color(self._apple_colour) apples_text.to_edge(UP) apples_text.align_to(text_two, LEFT) apple_count_text = TextMobject(f"{self._apple_count}") apple_count_text.set_color(self._apple_colour) apple_count_text.next_to(apples_text, RIGHT) banana_text = TextMobject("Bananas:") banana_text.set_color(self._banana_colour) banana_text.next_to(apples_text, DOWN) banana_text.align_to(apples_text, LEFT) banana_count_text = TextMobject(f"{self._banana_count}") banana_count_text.set_color(self._banana_colour) banana_count_text.next_to(banana_text, RIGHT) self.play(Transform(text_one, apples_text)) self.play(ShowCreation(apple_count_text)) self.play(ShowCreation(banana_text), ShowCreation(banana_count_text)) banana_bar = Rectangle( height=0.4, width=number_line.point_to_number(self._banana_fraction * 10) * (number_line.number_to_point(1)[0]), color=self._banana_colour, fill_color=self._banana_colour, fill_opacity=0.75) banana_bar.next_to(banana_count_text, RIGHT + RIGHT) apple_bar = Rectangle( height=0.4, width=number_line.point_to_number(self._apple_fraction * 10) * (number_line.number_to_point(1)[0]), color=self._apple_colour, fill_color=self._apple_colour, fill_opacity=0.75) apple_bar.next_to(banana_bar, UP) apple_bar.align_to(banana_bar, LEFT) self.play(FadeIn(apple_bar), FadeIn(banana_bar)) self.wait(1.5) apple_fraction_text = TextMobject("$\\frac{" + str(self._apple_count) + "}{" + str(self._apple_count + self._banana_count) + "} = " + str(self._apple_fraction) + "$") apple_fraction_text.next_to(apple_bar, RIGHT) banana_fraction_text = TextMobject("$\\frac{" + str(self._banana_count) + "}{" + str(self._apple_count + self._banana_count) + "} = " + str(self._banana_fraction) + "$") banana_fraction_text.next_to(banana_bar, RIGHT) self.play(ShowCreation(apple_fraction_text)) self.play(ShowCreation(banana_fraction_text)) self.wait(2) number_line_map_text = TextMobject( "Map these counts to values between 0 and 1") number_line_map_text.next_to(text_two, UP) self.play(ShowCreation(number_line_map_text)) self.wait(3) self.play(Transform(number_line_map_text, number_line)) apple_num_ln_bar = Rectangle( height=0.4, # width=1 - self._apple_fraction * (number_line.number_to_point(1)[0]), width=number_line.point_to_number(self._apple_fraction * 10) * (number_line.number_to_point(1)[0]), color=self._apple_colour, fill_color=self._apple_colour, fill_opacity=0.25) apple_num_ln_bar.move_to(apple_bar, LEFT) self.add(apple_num_ln_bar) self.wait(2) self.play( ApplyMethod(apple_num_ln_bar.move_to, number_line.number_to_point(0), LEFT)) banana_num_ln_bar = Rectangle( height=0.4, width=number_line.point_to_number(self._banana_fraction * 10) * (number_line.number_to_point(1)[0]), color=self._banana_colour, fill_color=self._banana_colour, fill_opacity=0.25) banana_num_ln_bar.move_to(banana_bar, LEFT) self.add(banana_num_ln_bar) self.wait(2) self.play( ApplyMethod(banana_num_ln_bar.move_to, number_line.number_to_point(1), RIGHT)) text_scale: float = 0.75 get_rnd_full = TextMobject( "Get a random number $n$ between 0 and 1 (uniform distribution)") get_apple_text = TextMobject( f"Apple\\quad if $n <= {self._apple_fraction}$", tex_to_color_map={"Apple": self._apple_colour}) get_banana_text = TextMobject( f"Banana\\quad if $n > {self._apple_fraction}$", tex_to_color_map={"Banana": self._banana_colour}) get_rnd_full.scale(text_scale) get_rnd_full.next_to(text_two, DOWN) get_banana_text.next_to(get_apple_text, DOWN) step_group = VGroup(get_apple_text, get_banana_text) brace = Brace(step_group, LEFT) step_text_d = brace.get_text("$n \\sim U(0, 1)$") step_text_d.scale(text_scale) step_text_d.next_to(get_rnd_full, DOWN + DOWN) step_text_d.shift(LEFT) brace.next_to(step_text_d, RIGHT) step_group.scale(text_scale) step_group.next_to(step_text_d, RIGHT + RIGHT + RIGHT) self.wait(2) self.play(ShowCreation(get_rnd_full)) self.wait(2) self.play(ShowCreation(step_text_d)) self.wait(2) self.play(GrowFromCenter(brace)) self.wait() self.play(ShowCreation(get_apple_text)) self.wait(2) self.play(ShowCreation(get_banana_text)) # random_nos_to_draw = 10 # main_arrow = Arrow(ORIGIN, DOWN * 1.3) # helper_arrow = Arrow(ORIGIN, LEFT * 1.3) # # for i in range(random_nos_to_draw): # num: float = np.random.random_sample(1) # point = number_line.number_to_point(num) # arrow_colour = self._apple_colour if num <= self._apple_fraction else self._banana_colour # arrow_recipient = get_apple_text if num <= self._apple_fraction else get_banana_text # # main_arrow.set_color(arrow_colour) # # if i == 0: # main_arrow.next_to(point, UP) # helper_arrow.next_to(arrow_recipient, RIGHT) # self.play(GrowArrow(main_arrow), GrowArrow(helper_arrow)) # else: # self.play(ApplyMethod(helper_arrow.next_to, arrow_recipient, RIGHT), # ApplyMethod(main_arrow.next_to, point, UP)) # self.wait() # # self.play(FadeOut(main_arrow), FadeOut(helper_arrow)) self.wait()
def __init__(self, screen01=[], screen02=[], screen03=[], lag_ratio=1, **kwargs): mobjs_1, mobjs_1_scale, mobjs_1_interval, mobjs_1_rate_func, \ title_1, title_1_color, title_1_scale, title_1_position, title_1_shadow, \ title_1_indicate_scale_factor, title_1_extra = screen01 + \ ["", 2, 0.5, linear, "", "#0808B8", 2, [DOWN], [2, slice(0, 3, 2)], 1.2, ""][len(screen01):] mobjs_2, mobjs_2_scale, mobjs_2_interval, mobjs_2_rate_func, \ title_2, title_2_color, title_2_scale, title_2_position, title_2_shadow, \ title_2_indicate_scale_factor, title_2_extra = screen02 + \ ["", 2, 0.5, linear, "", "#0808B8", 1.2, [DOWN], [2, slice(1, 4, 2)], "", [slice(1, 2), WHITE, [-2.5, 0, 0]]][len(screen02):] [title, subtitle, filename, reference, warning, mobjes_3_run_time] =\ screen03 + [[], [], [], [], [], 3][len(screen03):] [title, title_color, title_scale, title_position] = title + \ ["", WHITE, 1, [UP]][len(title):] [subtitle, subtitle_color, subtitle_scale, subtitle_position] = subtitle + \ ["", WHITE, 1, [0, 0, 0]][len(subtitle):] [filename, filename_color, filename_scale, filename_position] = filename + \ ["", WHITE, 1, [0, -2.9, 0]][len(filename):] [reference, reference_color, reference_scale, reference_position] = reference + \ ["", YELLOW, 1, [0, -3.3, 0]][len(reference):] [warning, warning_color, warning_scale, warning_position] = warning + \ ["", YELLOW, 1, [0, -3.7, 0] ][len(warning):] startscreens = AGroup() if mobjs_1 != None: if mobjs_1 == "": try: mobjs_1 = ImageMobjectGroup( np.char.mod('%01d', range(0, 10)), "sidewayoutput\\sidewayoutput2020yt") except: mobjs_1 = ImageMobjectGroup( np.char.mod('%01d', range(9, -1, -1)), "001\\") if title_1 == "": title_1 = PoweredBy title_1 = MobjectOrChars(title_1) title_1.set_color(title_1_color).scale( title_1_scale).align_on_border( *title_1_position).add_shadow_mobjects( title_1_shadow[0], title_1[title_1_shadow[1]]) if title_1_extra != "": title_1[title_1_extra[0]].set_color(title_1_extra[1]).shift( title_1_extra[2]) if title_1_indicate_scale_factor == "": title_width = mobjs_1.get_width() title_1_indicate_scale_factor = (title_width - 0.5) / title_width startscreens.add( ShowSubmobjectsOneByOneAndFadeInThenIndicateThenFadeOut( mobjs_1.scale(mobjs_1_scale), title_1, indicate_scale_factor=title_1_indicate_scale_factor, show_rate_func=mobjs_1_rate_func, run_time=mobjs_1_interval * (len(mobjs_1)), **kwargs)) if mobjs_2 != None: if mobjs_2 == "": strs = TextMobject(r"\textspA{%s}" % Project) mobjs_2 = Group( Circle(fill_opacity=0.75), RegularPolygon(fill_opacity=0.75), Triangle(color=GREEN, fill_opacity=0.75), Square(fill_opacity=0.75), strs.set_color("#FFFFFF"), strs.copy().set_color("#F8F8F8").scale(1.3), strs.copy().set_color("#F8F8B8").scale(1.6), strs.copy().set_color("#B8B8B8").scale(1.6), strs.copy().set_color("#8888B8").scale(1.6), strs.copy().set_color("#6868B8").scale(1.6), strs.copy().set_color("#4848B8").scale(1.6), strs.copy().set_color("#2828B8").scale(1.6), strs.copy().set_color("#0808B8").scale(1.6), ) if title_2 == "": title_2 = (r"{\tiny{\emph{Powered by}:}}\\ ", *PoweredBy) title_2 = MobjectOrChars(title_2) title_2.set_color(title_2_color).scale( title_2_scale).align_on_border( *title_2_position).add_shadow_mobjects( title_2_shadow[0], title_2[title_2_shadow[1]]) if title_2_extra != "": title_2[title_2_extra[0]].set_color(title_2_extra[1]).shift( title_2_extra[2]) if title_2_indicate_scale_factor == "": title_width = mobjs_2.get_width() title_2_indicate_scale_factor = (title_width - 0.5) / title_width startscreens.add( ShowSubmobjectsOneByOneAndFadeInThenIndicateThenFadeOut( mobjs_2.scale(mobjs_2_scale), title_2, indicate_scale_factor=title_2_indicate_scale_factor, show_rate_func=mobjs_2_rate_func, run_time=mobjs_2_interval * (len(mobjs_2)), **kwargs)) if title != None or subtitle != None: mobjs_3 = [Group(), "", ""] if title != None: txt_title = TextMobject(title).scale(title_scale) if txt_title.get_width() > 14: txt_title.stretch_to_fit_width(14) mobjs_3[1] = txt_title.set_color(title_color).to_edge( *title_position) mobjs_3[0].add(mobjs_3[1]) if subtitle != None: mobjs_3[0].add( TextMobject(subtitle).set_color(subtitle_color).scale( subtitle_scale).shift(subtitle_position)) if filename != None and filename != "": if reference == None or reference == "": filename_position = reference_position mobjs_3[0].add( TextMobject(filename).set_color(filename_color).scale( filename_scale).shift(filename_position)) if reference != None and reference != "": txt_reference = TextMobject(reference).scale(reference_scale) if txt_reference.get_width() > 14: txt_reference.stretch_to_fit_width(14) mobjs_3[0].add( txt_reference.set_color(reference_color).shift( reference_position)) if warning != None and warning != "": txt_warning = TextMobject(warning).scale( warning_scale) # height=0.3 if txt_warning.get_width() > 14: txt_warning.stretch_to_fit_width(14) mobjs_3[2] = txt_warning.set_color(warning_color).shift( warning_position) animations = AGroup() if len(mobjs_3[0]) > 0: animations.add( FadeIn(mobjs_3[0], run_time=0.5, scale_factor=1, color=None)) if len(mobjs_3[1]) > 0: animations.add(GrowFromCenter(Underline(mobjs_3[1]))) if len(mobjs_3[2]) > 0: animations.add( FadeInThenIndicate(mobjs_3[2], run_time=0.5, scale_factor=1.2, color=None)) startscreens.add( FadeoutSuccession(AnimationGroup(*animations, run_time=mobjes_3_run_time), run_time=0.05)) super().__init__(AnimationGroup(*startscreens, lag_ratio=1), **kwargs)
def get_author(self, quote): author = TextMobject(self.text_size + " --" + self.author) author.next_to(quote, DOWN, buff=self.author_buff) author.set_color(YELLOW) return author
def scroll_through_patrons(self): logo_box = Square(side_length=2.5) logo_box.to_corner(DOWN + LEFT, buff=MED_LARGE_BUFF) total_width = FRAME_X_RADIUS - logo_box.get_right()[0] black_rect = Rectangle( fill_color=BLACK, fill_opacity=1, stroke_width=3, stroke_color=BLACK, width=FRAME_WIDTH, height=0.6 * FRAME_HEIGHT, ) black_rect.to_edge(UP, buff=0) line = DashedLine(FRAME_X_RADIUS * LEFT, FRAME_X_RADIUS * RIGHT) line.move_to(ORIGIN) thanks = TextMobject(self.thanks_words) thanks.scale(0.9) thanks.next_to(black_rect.get_bottom(), UP, SMALL_BUFF) thanks.set_color(YELLOW) underline = Line(LEFT, RIGHT) underline.match_width(thanks) underline.scale(1.1) underline.next_to(thanks, DOWN, SMALL_BUFF) thanks.add(underline) changed_patron_names = map( self.modify_patron_name, self.specific_patrons, ) patrons = VGroup(*map( TextMobject, changed_patron_names, )) patrons.scale(self.patron_scale_val) for patron in patrons: if patron.get_width() > self.max_patron_width: patron.set_width(self.max_patron_width) columns = VGroup(*[ VGroup(*patrons[i::self.n_patron_columns]) for i in range(self.n_patron_columns) ]) for column in columns: for n, name in enumerate(column): name.shift(n * self.name_y_spacing * DOWN) columns.arrange( RIGHT, buff=LARGE_BUFF, aligned_edge=UP, ) if columns.get_width() > self.max_patron_width: columns.set_width(total_width - 1) thanks.to_edge(RIGHT, buff=MED_SMALL_BUFF) columns.next_to(underline, DOWN, buff=2) columns.generate_target() columns.target.to_edge(DOWN, buff=2) vect = columns.target.get_center() - columns.get_center() distance = get_norm(vect) wait_time = 20 always_shift( columns, direction=normalize(vect), rate=(distance / wait_time) ) self.add(columns, black_rect, line, thanks) self.wait(wait_time)