def construct(self): circle = Circle(color=PURPLE_A) square = Square(fill_color=GOLD_B, fill_opacity=1, color=GOLD_A) square.move_to(UP + LEFT) circle.surround(square) rectangle = Rectangle(height=2, width=3) ellipse = Ellipse(width=3, height=1, color=RED) ellipse.shift(2 * DOWN + 2 * RIGHT) pointer = CurvedArrow(2 * RIGHT, 5 * RIGHT, color=MAROON_C) arrow = Arrow(LEFT, UP) arrow.next_to(circle, DOWN + LEFT) rectangle.next_to(arrow, DOWN + LEFT) circle2 = Circle() circle2.surround(rectangle, buffer_factor=1) ring = Annulus(inner_radius=.5, outer_radius=1, color=BLUE) ring.next_to(ellipse, RIGHT) self.add(pointer) self.add(circle2) self.play(FadeIn(square)) self.play(Rotating(square), FadeIn(circle)) self.play(GrowArrow(arrow)) self.play(GrowFromCenter(rectangle), GrowFromCenter(ellipse), GrowFromCenter(ring)) self.wait()
def __init__(self, side_length: int = 2, **kwargs): super().__init__(**kwargs) face = Square(side_length=side_length) face.get_triangulation() self.add(*Cube.square_to_cube_faces(face)) self.init_colors() self.apply_depth_test() self.refresh_unit_normal()
def generate_points(self): for vect in IN, OUT, LEFT, RIGHT, UP, DOWN: face = Square( side_length=self.side_length, shade_in_3d=True, ) face.make_jagged() face.flip() face.shift(self.side_length * OUT / 2.0) face.apply_matrix(z_to_vector(vect)) self.add(face)
def __init__(self, side_length: float = 2.0, **kwargs): face = Square(side_length=side_length) super().__init__(*Cube.square_to_cube_faces(face), **kwargs) self.init_colors() self.set_joint_type(self.joint_type) self.apply_depth_test() self.refresh_unit_normal()
def construct(self): square = Square(side_length=5, fill_color=YELLOW, fill_opacity=1) label = TextMobject("Text at an angle") label_bg = BackgroundRectangle(label, fill_opacity=1) label_group = VGroup(label_bg, label) label_group.rotate(TAU / 8) label2 = TextMobject("Boxed text", color=BLACK) label2_bg = SurroundingRectangle(label2, color=BLUE, fill_color=RED, fill_opacity=.5) label2_group = VGroup(label2, label2_bg) label2_group.next_to(label_group, DOWN) label3 = TextMobject("Rainbow") label3.scale(2) label3.set_color_by_gradient(RED, GREEN, BLUE) label3.to_edge(DOWN) self.add(square) self.play(FadeIn(label_group)) self.play(FadeIn(label2_group)) self.play(FadeIn(label3)) self.wait(2)
def generate_points(self): n = self.n self.small_squares = VGroup(*[ Square(side_length = 1, stroke_color = GREY, stroke_width = 3) for k in range(n**4) ]) self.small_squares.arrange_submobjects_in_grid(n**2, n**2, buff = 0) self.big_squares = VGroup(*[ Square(side_length = self.n, stroke_color = WHITE, stroke_width = 8) for k in range(n**2) ]) self.big_squares.arrange_submobjects_in_grid(n, n, buff = 0) self.entries = dict() self.add(self.small_squares, self.big_squares) self.center() self.set_height(self.height)
def __init__(self, **kwargs): if not hasattr(self, "args"): self.args = serialize_args([]) if not hasattr(self, "config"): self.config = serialize_config({ **kwargs, }) super().__init__(**kwargs) body = Cube(side_length=1) for dim, scale_factor in enumerate(self.body_dimensions): body.stretch(scale_factor, dim=dim) body.set_width(self.width) body.set_fill(self.shaded_body_color, opacity=1) body.sort(lambda p: p[2]) body[-1].set_fill(self.body_color) screen_plate = body.copy() keyboard = VGroup(*[ VGroup( *[Square(**self.key_color_kwargs) for x in range(12 - y % 2)]).arrange(RIGHT, buff=SMALL_BUFF) for y in range(4) ]).arrange(DOWN, buff=MED_SMALL_BUFF) keyboard.stretch_to_fit_width( self.keyboard_width_to_body_width * body.get_width(), ) keyboard.stretch_to_fit_height( self.keyboard_height_to_body_height * body.get_height(), ) keyboard.next_to(body, OUT, buff=0.1 * SMALL_BUFF) keyboard.shift(MED_SMALL_BUFF * UP) body.add(keyboard) screen_plate.stretch(self.screen_thickness / self.body_dimensions[2], dim=2) screen = Rectangle( stroke_width=0, fill_color=BLACK, fill_opacity=1, ) screen.replace(screen_plate, stretch=True) screen.scale_in_place(self.screen_width_to_screen_plate_width) screen.next_to(screen_plate, OUT, buff=0.1 * SMALL_BUFF) screen_plate.add(screen) screen_plate.next_to(body, UP, buff=0) screen_plate.rotate(self.open_angle, RIGHT, about_point=screen_plate.get_bottom()) self.screen_plate = screen_plate self.screen = screen axis = Line(body.get_corner(UP + LEFT + OUT), body.get_corner(UP + RIGHT + OUT), color=BLACK, stroke_width=2) self.axis = axis self.add(body, screen_plate, axis) self.rotate(5 * np.pi / 12, LEFT, about_point=ORIGIN) self.rotate(np.pi / 6, DOWN, about_point=ORIGIN)
def init_tiles(self): out_std = Square(side_length=1, **self.tile_config) out_std.shift((RIGHT + UP) / 2.) dim = self.dimension out_tiles = VGroup() for i in range(dim**2): tile = out_std.copy() tile.shift((i % dim) * UP + (i // dim) * RIGHT) out_tiles.add(tile) up_tiles = out_tiles.copy() up_tiles.rotate(-2. * np.pi / 3., axis=[1, 1, 1], about_point=ORIGIN) right_tiles = out_tiles.copy() right_tiles.rotate(2. * np.pi / 3., axis=[1, 1, 1], about_point=ORIGIN) all_tiles = [out_tiles, right_tiles, up_tiles] for tile_set, color in zip(all_tiles, self.tile_colors): for tile in tile_set: tile.set_fill(color=color, opacity=self.enable_fill) self.backup_tiles = VGroup(*all_tiles).copy()
def get_color_palette(self): palette = VGroup( *(Square(fill_color=color, fill_opacity=1, side_length=1) for color in self.palette_colors)) palette.set_stroke(width=0) palette.arrange(RIGHT, buff=0.5) palette.set_width(FRAME_WIDTH - 0.5) palette.to_edge(DOWN, buff=SMALL_BUFF) palette.fix_in_frame() return palette
def construct(self): circle = Circle() square = Square() self.add(circle) self.add(square) self.play(UpdateFromAlphaFunc(circle, self.update_stuff), UpdateFromAlphaFunc(square, self.update_stuff, rate_func=linear)) self.wait()
def add_board(self): board = VGroup(*[ Square( side_length = 0.8, stroke_width = 0, fill_opacity = 1, fill_color = CB_DARK if (i+j)%2!=0 else CB_LIGHT ) for i in range(8) for j in range(8) ]) board.arrange_submobjects_in_grid(8, 8, buff = 0) self.add(board) self.board = board
def get_background(self): single_square_len = self.background_grid_kwargs["single_square_len"] colors = self.background_grid_kwargs["colors"] width = self.rect_kwargs["width"] height = self.rect_kwargs["height"] rows = int(height / single_square_len) cols = int(width / single_square_len) cols = (cols + 1) if (cols % 2 == 0) else cols single_square = Square(single_square_len) grid = single_square.get_grid(n_rows=rows, n_cols=cols, buff=0.0) grid.stretch_to_fit_width(width) grid.stretch_to_fit_height(height) grid.move_to(self.selected_color_box) for idx, square in enumerate(grid): assert (isinstance(square, Square)) square.set_stroke(width=0.0, opacity=0.0) square.set_fill(colors[idx % len(colors)], 1.0) return grid
def construct(self): circle = Circle() square = Square() line = Line((3, 0, 0), (5, 0, 0)) triangle = Polygon((0, 0, 0), (1, 1, 0), (1, -1, 0)) self.play(ShowCreation(circle), run_time=5) self.play(FadeOut(circle), GrowFromCenter(square)) self.add(line) self.play(Transform(square, triangle)) self.play(Transform(triangle)) self.wait()
def generate_points(self): for vect in IN, OUT, LEFT, RIGHT, UP, DOWN: face = Square( side_length=self.side_length, shade_in_3d=True, ) face.flip() face.shift(self.side_length * OUT / 2.0) face.apply_matrix(z_to_vector(vect)) self.add(face)
def construct(self): circle = Circle() square = Square() line = Line(np.array([3, 0, 0]), np.array([5, 0, 0])) triangle = Polygon(np.array([0, 0, 0]), np.array([1, 1, 0]), np.array([1, -1, 0])) self.add(line) self.play(ShowCreation(circle)) self.play(FadeOut(circle)) self.play(GrowFromCenter(square)) self.play(Transform(square, triangle)) self.wait()
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 generate_symbol(self): symbol = Square(stroke_width = 0, fill_color = self.color, fill_opacity = 1) symbol.set_height(self.inner_radius * 0.8) return symbol
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 add_border(self): border = Square(side_length = self.board.get_height()) border.move_to(self.board.get_center()) self.add(border) self.border = border
def generate_points(self): qed = Square(fill_color = self.color, fill_opacity = 1, stroke_width = 0) self.add(qed) self.set_height(self.height)
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 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)
def construct(self): if 1 == 1: try: self.add_sound( "sidewayoutput\\basicmanim\\transform001a_01_01_01_01_01.wav", time_offset=18) self.add_sound( "sidewayoutput\\basicmanim\\transform001a_01_01_01_02_01.wav", time_offset=93) self.add_sound( "sidewayoutput\\basicmanim\\transform001a_01_01_01_03_01.wav", time_offset=135) except: pass self.play( StartScreens01( [], [], [[r"\textbf{\textit{Basic-Manim from }\{Sideway\}}"], [r"\textbf{\textit{Transform}}\\{{Part\ \textspA{I}a}"], [ r"\tiny{\textrm{basic-manim.210200551v0\_transform001a}}" ], [], [ r"\scriptsize{\textbf{Warning:\ The\ content\ may\ contain\ errors,\ mistakes\ and\ inaccuracies.\ Information\ must\ be\ verified\ and\ evaluated\ before\ use.}}" ]], )) if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Transform}}}").shift( [0, 3.6, 0]))) squarea = Square() squareb = Square(side_length=4).shift([4, 0, 0]) circlea = Circle() circleb = Circle(radius=2).shift([-4, 0, 0]) linea = Line([-4, 3, 0], [4, 3, 0]) lineb = Line([-3, -3, 0], [3, -3, 0]) texta = TextMobject("AB").shift([0, -2.5, 0]) textb = TextMobject("HI").shift([0, 2.5, 0]) self.play( ShowCreation(Group(squarea, circlea, squareb, circleb, linea, lineb), lag_ratio=1, run_time=12)) self.play(Write(VGroup(texta, textb), lag_ratio=1, run_time=10)) self.play(Transform(circlea, squarea, run_time=5)) self.play(Transform(circlea, squareb, path_arc=3, run_time=5)) self.play(Transform(squarea, circleb, path_arc=3, run_time=5)) self.play(Transform(linea, lineb, path_arc=3, run_time=5)) self.play(Transform(linea, circleb, path_arc=3, run_time=5)) self.play(Transform(squareb, lineb, path_arc=3, run_time=5)) self.play(Transform(texta, textb, path_arc=3, run_time=5)) self.play(Transform(texta, circleb, path_arc=3, run_time=5)) self.play(Transform(squareb, textb, path_arc=3, run_time=5)) self.fadeout() if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Paths\ of\ Transform}}}"). shift([0, 3.6, 0]))) rows, cols = (7, 5) x0, y0 = axes_point([0, 2, cols - 1, -4], [2.3, -1, rows - 1, 3]) txtx = ["loc 1", "loc 2", "m1", "m2"] txty = [ "ClockwiseTransform", "Transform", "CounterclockwiseTransform" ] a1 = Group() a2 = Group() a3 = Group() a4 = Group() for j in range(1, rows): a1.add(Circle().scale(0.2).move_to([x0[1], y0[j], 0])) a2.add(Square().scale(0.2).move_to([x0[2], y0[j], 0])) a3.add( Dot([x0[3], y0[j], 0]).add_updater(lambda mob, obj=a1[ j - 1], x=x0[3], y=y0[j]: mob.become(obj.copy( ).move_to([x, y, 0]))).suspend_updating()) a4.add( Dot([x0[4], y0[j], 0]).add_updater(lambda mob, obj=a2[ j - 1], x=x0[4], y=y0[j]: mob.become(obj.copy( ).move_to([x, y, 0]))).suspend_updating()) self.play(FadeIn( Group( *[ TextMobject(txtx[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:], y0[0:1])) ], *[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[1::2])) ], *[Dot(each) for each in coord_grid(x0[1:3], y0[1:])], TextMobject(r"$\rightarrow$").move_to( ([(x0[1] + x0[2]) / 2, y0[0], 0])), a1[::2], a2[::2], a3, a4, *[ Square(stroke_width=2, color="#FFFF00", fill_opacity=0.3).add_updater( lambda mob, obj=obj: mob.surround( obj, stretch=True, buff=0.2)) for obj in a1 ], *[ Square(stroke_width=2, color="#DC75CD").add_updater( lambda mob, obj=obj: mob.surround( obj, stretch=True, buff=0.3)) for obj in a2 ])), run_time=5) self.wait(2) self.play(AnimationGroup( ClockwiseTransform(a2[0], a1[0]), ClockwiseTransform(a1[1], a2[1]), Transform(a1[2], a2[2]), Transform(a2[3], a1[3]), CounterclockwiseTransform(a1[4], a2[4]), CounterclockwiseTransform(a2[5], a1[5]), ), run_time=25) self.wait(3) a1.shift([0.3, 0, 0]).set_color("#11FF00") self.wait(3) self.play(ApplyMethod(a1.shift, ([0.3, 0, 0])), run_time=3) self.fadeout() if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Methods\ of\ Transform}}}" ).shift([0, 3.6, 0]))) rows, cols = (9, 5) x0, y0 = axes_point([0, 2, cols - 1, -4], [2.3, -0.8, rows - 1, 3]) txtx = ["loc 1", "loc 2", "m1", "m2"] txty = [ "Transform", "ReplacementTransform", "TransformFromCopy", "MoveToTarget" ] a1 = Group() a2 = Group() a3 = Group() a4 = Group() for j in range(1, rows): a1.add(Circle().scale(0.2).move_to([x0[1], y0[j], 0])) a2.add(Square().scale(0.2).move_to([x0[2], y0[j], 0])) a3.add(Dot().move_to([x0[3], y0[j], 0]).add_updater( lambda mob, obj=a1[j - 1], x=x0[3], y=y0[j]: mob.become( obj.copy().move_to([x, y, 0]))).suspend_updating()) a4.add(Dot().move_to([x0[4], y0[j], 0]).add_updater( lambda mob, obj=a2[j - 1], x=x0[4], y=y0[j]: mob.become( obj.copy().move_to([x, y, 0]))).suspend_updating()) a1[6].target = a2[6] a1[7].target = a2[7] self.play(FadeIn( Group( *[ TextMobject(txtx[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:], y0[0:1])) ], *[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[1::2])) ], *[Dot(each) for each in coord_grid(x0[1:3], y0[1:])], TextMobject(r"$\rightarrow$").move_to( ([(x0[1] + x0[2]) / 2, y0[0], 0])), a1[::2], a2[::2], a3, a4, Group(*[ Square( stroke_width=2, color="#FFFF00", fill_opacity=0.3). add_updater(lambda mob, obj=obj: mob.surround( obj, stretch=True, buff=0.2)) for obj in a1 ]), Group(*[ Square(stroke_width=2, color="#DC75CD").add_updater( lambda mob, obj=obj: mob.surround( obj, stretch=True, buff=0.3)) for obj in a2 ]))), run_time=5) self.wait(2) self.play(AnimationGroup(Transform(a1[0], a2[0]), Transform(a1[1], a2[1]), ReplacementTransform(a1[2], a2[2]), ReplacementTransform(a1[3], a2[3]), TransformFromCopy(a1[4], a2[4]), TransformFromCopy(a1[5], a2[5]), MoveToTarget(a1[6]), MoveToTarget(a1[7])), run_time=40) self.wait(3) a1.shift([0.3, 0, 0]).set_color("#11FF00") self.wait(10) self.play(ApplyMethod(a1.shift, ([0.3, 0, 0])), run_time=5) self.fadeout() if 1 == 1: self.play(EndScreen01()) self.wait(5)