def construct(self): curve = HilbertCurve(order = 6) curve.highlight(WHITE) colored_curve = curve.copy() colored_curve.thin_out(3) lion = ImageMobject("lion", invert = False) lion.replace(curve, stretch = True) sparce_lion = lion.copy() sparce_lion.thin_out(100) distance_matrix = cdist(colored_curve.points, sparce_lion.points) closest_point_indices = np.apply_along_axis( np.argmin, 1, distance_matrix ) colored_curve.rgbs = sparce_lion.rgbs[closest_point_indices] line = Line(5*LEFT, 5*RIGHT) Mobject.align_data(line, colored_curve) line.rgbs = colored_curve.rgbs self.add(lion) self.play(ShowCreation(curve, run_time = 3)) self.play( FadeOut(lion), Transform(curve, colored_curve), run_time = 3 ) self.dither() self.play(Transform(curve, line, run_time = 5)) self.dither()
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 construct(self): words = TextMobject("Yet another bit of Mark Levi cleverness") words.to_edge(UP) levi = ImageMobject("Mark_Levi", invert = False) levi.scale_to_fit_width(6) levi.show() self.add(levi) self.play(ShimmerIn(words)) self.dither(2)
def construct(self): name = TextMobject("Steven Strogatz") name.to_edge(UP) contributions = TextMobject("Frequent Contributions") contributions.scale(0.5).to_edge(RIGHT).shift(2 * UP) books_word = TextMobject("Books") books_word.scale(0.5).to_edge(LEFT).shift(2 * UP) radio_lab, sci_fri, cornell, book2, book3, book4 = [ ImageMobject(filename, invert=False, filter_color=WHITE) for filename in [ "radio_lab", "science_friday", "cornell", "strogatz_book2", "strogatz_book3", "strogatz_book4", ] ] book1 = ImageMobject("strogatz_book1", invert=False) nyt = ImageMobject("new_york_times") logos = [radio_lab, nyt, sci_fri] books = [book1, book2, book3, book4] sample_size = Square(side_length=2) last = contributions for image in logos: image.replace(sample_size) image.next_to(last, DOWN) last = image sci_fri.scale_in_place(0.9) shift_val = 0 sample_size.scale(0.75) for book in books: book.replace(sample_size) book.next_to(books_word, DOWN) book.shift(shift_val * (RIGHT + DOWN)) shift_val += 0.5 sample_size.scale(2) cornell.replace(sample_size) cornell.next_to(name, DOWN) self.add(name) self.play(FadeIn(cornell)) self.play(ShimmerIn(books_word)) for book in books: book.shift(5 * LEFT) self.play(ApplyMethod(book.shift, 5 * RIGHT)) self.play(ShimmerIn(contributions)) for logo in logos: self.play(FadeIn(logo)) self.wait()
def construct(self): europe = ImageMobject("Europe", use_cache = False) self.add(europe) self.freeze_background() mathematicians = [ ("Newton", [-1.75, -0.75, 0]), ("Jacob_Bernoulli",[-0.75, -1.75, 0]), ("Ehrenfried_von_Tschirnhaus",[0.5, -0.5, 0]), ("Gottfried_Wilhelm_von_Leibniz",[0.2, -1.75, 0]), ("Guillaume_de_L'Hopital", [-1.75, -1.25, 0]), ] for name, point in mathematicians: man = ImageMobject(name, invert = False) if name == "Newton": name = "Isaac_Newton" name_mob = TextMobject(name.replace("_", " ")) name_mob.to_corner(UP+LEFT, buff=0.75) self.add(name_mob) man.scale_to_fit_height(4) mobject = Point(man.get_corner(UP+LEFT)) self.play(Transform(mobject, man)) man.scale(0.2) man.shift(point) self.play(Transform(mobject, man)) self.remove(name_mob)
def construct(self): old_newton = ImageMobject("Old_Newton", invert=False) old_newton.scale(0.8) self.add(old_newton) self.freeze_background() words = TextMobject("Note the displeasure") words.to_corner(UP + RIGHT) face_point = 1.8 * UP + 0.5 * LEFT arrow = Arrow(words.get_bottom(), face_point) self.play(ShimmerIn(words)) self.play(ShowCreation(arrow)) self.wait()
def construct(self): one_solution = TextMobject(["One ", "solution"]) two_insights = TextMobject(["Two ", " insights"]) two, insights = two_insights.split() johann = ImageMobject("Johann_Bernoulli2", invert=False) mark = ImageMobject("Mark_Levi", invert=False) for mob in johann, mark: mob.scale(0.4) johann.next_to(insights, LEFT) mark.next_to(johann, RIGHT) name = TextMobject("Mark Levi").to_edge(UP) self.play(*map(ShimmerIn, one_solution.split())) self.dither() for pair in zip(one_solution.split(), two_insights.split()): self.play(Transform(*pair, path_func=path_along_arc(np.pi))) self.dither() self.clear() self.add(two, insights) for word, man in [(two, johann), (insights, mark)]: self.play(Transform(word, Point(word.get_left())), GrowFromCenter(man)) self.dither() self.clear() self.play(ApplyMethod(mark.center)) self.play(ShimmerIn(name)) self.dither()
def construct(self): old_newton = ImageMobject("Old_Newton", invert = False) old_newton.scale(0.8) self.add(old_newton) self.freeze_background() words = TextMobject("Note the displeasure") words.to_corner(UP+RIGHT) face_point = 1.8*UP+0.5*LEFT arrow = Arrow(words.get_bottom(), face_point) self.play(ShimmerIn(words)) self.play(ShowCreation(arrow)) self.dither()
def construct(self): headphones = ImageMobject("Headphones.png") headphones.scale(0.1) headphones.stretch(2, 0) headphones.shift(1.2*UP+0.05*LEFT) headphones.highlight(GREY) randy = Randolph() self.add(randy, headphones) self.dither(2) self.play(ApplyMethod(randy.blink)) self.dither(4)
def construct(self): mathematicians = [ ImageMobject(name, invert=False) for name in [ "Old_Newton", "Johann_Bernoulli2", "Jacob_Bernoulli", "Ehrenfried_von_Tschirnhaus", "Gottfried_Wilhelm_von_Leibniz", "Guillaume_de_L'Hopital", ] ] newton = mathematicians.pop(0) newton.scale(0.8) new_newton = newton.copy() new_newton.scale_to_fit_height(3) new_newton.to_edge(UP) for man in mathematicians: man.scale_to_fit_width(1.7) johann = mathematicians.pop(0) johann.next_to(new_newton, DOWN) last_left, last_right = johann, johann for man, count in zip(mathematicians, it.count()): if count % 2 == 0: man.next_to(last_left, LEFT) last_left = man else: man.next_to(last_right, RIGHT) last_right = man self.play(Transform(newton, new_newton), GrowFromCenter(johann)) self.wait() self.play(FadeIn(Mobject(*mathematicians))) self.wait()
def construct(self): image = ImageMobject("lion", invert = False) image.scale(0.5) image.shift(2*LEFT) self.add(image) for vect, num in zip([DOWN, RIGHT], [1, 2]): brace = Brace(image, vect) words_mob = TextMobject("Dimension %d"%num) words_mob.next_to(image, vect, buff = 1) self.play( Transform(Point(brace.get_center()), brace), ShimmerIn(words_mob), run_time = 2 ) self.dither()
def construct(self): string = Vibrate(color = BLUE_D, run_time = 5) picture = ImageMobject("lion", invert = False) picture.scale(0.8) picture_copy = picture.copy() picture.sort_points(np.linalg.norm) string.mobject.sort_points(lambda p : -np.linalg.norm(p)) self.add(picture) self.dither() self.play(Transform( picture, string.mobject, run_time = 3, rate_func = rush_into )) self.remove(picture) self.play(string) for mob in picture_copy, string.mobject: mob.sort_points(lambda p : np.linalg.norm(p)%1) self.play(Transform( string.mobject, picture_copy, run_time = 5, rate_func = rush_from ))
def construct(self): #self.force_skipping() title = TextMobject("Set","Theory") title.scale(1.3) title.to_edge(UP) self.add(title) self.dither() cantor = ImageMobject("Georg_Cantor2") cantor.scale(0.5) cantor_desc = TextMobject("Georg Cantor") cantor_desc.next_to(cantor, DOWN) VGroup(cantor, cantor_desc).to_corner(UP+RIGHT) self.add(cantor) self.play(FadeIn(cantor), FadeIn(cantor_desc, submobject_mode = "lagged_start")) self.dither() studies0 = TextMobject("Study of","infinity") studies0[1].highlight(YELLOW) studies0.scale(1.3) studies0.shift(LEFT*cantor_desc.get_width()/2 + UP) self.play(FadeIn(studies0[0]), Write(studies0[1])) self.dither() studies1 = TextMobject("Study of","infinite","sets") studies1.scale(1.3) studies1.move_to(studies0) studies1[1].highlight(YELLOW) sets_ori = title[0].copy() s = studies1[-1][-1].copy() s.shift(sets_ori[-1].get_center() - studies1[-1][-2].get_center()) s.set_fill(opacity = 0) sets_ori.add(s) studies0.add(sets_ori) self.play(ReplacementTransform(studies0, studies1)) self.dither() self.play(studies1.next_to, title, DOWN, FadeOut(cantor), FadeOut(cantor_desc)) self.dither()
def construct(self): equation = TexMobject("2^{19} = " + "{:,}".format(2**19)) equation.scale_to_fit_width(SPACE_WIDTH) equation.to_edge(DOWN, buff=LARGE_BUFF) q_and_a = TextMobject("Q\\&A \\\\ Round 2") q_and_a.gradient_highlight(BLUE, YELLOW) q_and_a.scale_to_fit_width(SPACE_WIDTH) q_and_a.to_edge(UP, buff=LARGE_BUFF) eater = ImageMobject("eater", height=3) eater.to_corner(UP + RIGHT, buff=0) confetti_anims = get_confetti_animations(100) for anim in confetti_anims: anim.update(0.5) confetti = VGroup(*[a.mobject for a in confetti_anims]) self.add(equation, q_and_a, eater)
def construct(self): one_solution = TextMobject(["One ", "solution"]) two_insights = TextMobject(["Two ", " insights"]) two, insights = two_insights.split() johann = ImageMobject("Johann_Bernoulli2", invert = False) mark = ImageMobject("Mark_Levi", invert = False) for mob in johann, mark: mob.scale(0.4) johann.next_to(insights, LEFT) mark.next_to(johann, RIGHT) name = TextMobject("Mark Levi").to_edge(UP) self.play(*map(ShimmerIn, one_solution.split())) self.dither() for pair in zip(one_solution.split(), two_insights.split()): self.play(Transform(*pair, path_func = path_along_arc(np.pi))) self.dither() self.clear() self.add(two, insights) for word, man in [(two, johann), (insights, mark)]: self.play( Transform(word, Point(word.get_left())), GrowFromCenter(man) ) self.dither() self.clear() self.play(ApplyMethod(mark.center)) self.play(ShimmerIn(name)) self.dither()
def construct(self): title = TextMobject("(A few) Fathers of Calculus") title.to_edge(UP) self.add(title) men = Mobject() for name in self.names: image = ImageMobject(name, invert=False) image.scale_to_fit_height(self.picture_height) title = TextMobject(name) title.scale(0.8) title.next_to(image, DOWN) image.add(title) men.add(image) men.arrange_submobjects(RIGHT, aligned_edge=UP) men.shift(DOWN) discover_brace = Brace(Mobject(*men[:3]), UP) discover = discover_brace.get_text("Discovered it") VGroup(discover_brace, discover).highlight(BLUE) rigor_brace = Brace(Mobject(*men[3:]), UP) rigor = rigor_brace.get_text("Made it rigorous") rigor.shift(0.1 * DOWN) VGroup(rigor_brace, rigor).highlight(YELLOW) for man in men: self.play(FadeIn(man)) self.play(GrowFromCenter(discover_brace), Write(discover, run_time=1)) self.play(GrowFromCenter(rigor_brace), Write(rigor, run_time=1)) self.dither()
def construct(self): self.force_skipping() conversation = Conversation(self) conversation.add_bubble("A co sjednotit všechny ordinály?") self.revert_to_original_skipping_status() forti_pic = ImageMobject("BuraliForti1.jpg", use_cache = False) forti_pic.scale(0.43) forti_pic.to_corner(UP+LEFT) ordinal_class = OrdinalClass(color = BLUE).shift(UP) ordinal_class.next_to(forti_pic, coor_mask = X_MASK) num = 7 subordinals = VGroup([ordinal_class.copy() for _ in range(num)]) for subord, x in zip(subordinals, np.linspace(0.3, 1, num)): i = int(x*len(subord.line)) subord.line.remove(*subord.line[i:]) lines_dest = VGroup([subord.line for subord in subordinals]).copy() bars_dest = VGroup([subord.bars for subord in subordinals]).copy() subordinals.arrange_submobjects(UP, False, coor_mask = Y_MASK) subordinals.next_to(conversation.dialog, UP, coor_mask = Y_MASK) lines = VGroup([subord.line for subord in subordinals]) bars = VGroup([subord.bars for subord in subordinals]) self.wait_to(3) self.play(FadeIn(subordinals)) self.wait_to(4.5) self.play( Transform(lines, lines_dest), Transform(bars, bars_dest), ) self.remove(subordinals) self.add(ordinal_class) self.wait_to(6) conversation.add_bubble("Cesare Burali-Forti paradox") next_bar = ordinal_class.bars[0][0].copy().next_to(ordinal_class) next_bar.highlight(YELLOW) self.wait_to(9) self.play(ShowCreation(next_bar)) brace = BraceText(VGroup(ordinal_class, next_bar), "Nový ordinál", UP) self.wait_to(15) self.play(brace.creation_anim()) picture = VGroup(ordinal_class, brace, next_bar) picture.save_state() picture.next_to(forti_pic, coor_mask = X_MASK) self.wait_to(29) self.play(FadeIn(forti_pic)) self.wait_to(49) self.play(*map(FadeOut, [ picture, conversation.dialog, forti_pic, ]))
def construct(self): curve = HilbertCurve(order=6) curve.highlight(WHITE) colored_curve = curve.copy() colored_curve.thin_out(3) lion = ImageMobject("lion", invert=False) lion.replace(curve, stretch=True) sparce_lion = lion.copy() sparce_lion.thin_out(100) distance_matrix = cdist(colored_curve.points, sparce_lion.points) closest_point_indices = np.apply_along_axis(np.argmin, 1, distance_matrix) colored_curve.rgbs = sparce_lion.rgbs[closest_point_indices] line = Line(5 * LEFT, 5 * RIGHT) Mobject.align_data(line, colored_curve) line.rgbs = colored_curve.rgbs self.add(lion) self.play(ShowCreation(curve, run_time=3)) self.play(FadeOut(lion), Transform(curve, colored_curve), run_time=3) self.dither() self.play(Transform(curve, line, run_time=5)) self.dither()
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 construct(self): morty = Mortimer() morty.next_to(ORIGIN, DOWN) morty.to_edge(RIGHT) headphones = Headphones(height = 1) headphones.move_to(morty.eyes, aligned_edge = DOWN) headphones.shift(0.1*DOWN) url = TextMobject("www.audibletrial.com/3blue1brown") url.scale(0.8) url.to_corner(UP+RIGHT, buff = LARGE_BUFF) book = ImageMobject("zen_and_motorcycles") book.scale_to_fit_height(5) book.to_edge(DOWN, buff = LARGE_BUFF) border = Rectangle(color = WHITE) border.replace(book, stretch = True) self.play(PiCreatureSays( morty, "Book recommendation!", target_mode = "surprised" )) self.play(Blink(morty)) self.play( FadeIn(headphones), morty.change_mode, "thinking", FadeOut(morty.bubble), FadeOut(morty.bubble.content), ) self.play(Write(url)) self.play(morty.change_mode, "happy") self.dither(2) self.play(Blink(morty)) self.dither(2) self.play( morty.change_mode, "raise_right_hand", morty.look_at, url ) self.dither(2) self.play( morty.change_mode, "happy", morty.look_at, book ) self.play(FadeIn(book)) self.play(ShowCreation(border)) self.dither(2) self.play(Blink(morty)) self.dither() self.play( morty.change_mode, "thinking", morty.look_at, book ) self.dither(2) self.play(Blink(morty)) self.dither(4) self.play(Blink(morty))
def construct(self): dated_events = [ { "date" : 1696, "text": "Johann Bernoulli poses Brachistochrone problem", "picture" : "Johann_Bernoulli2" }, { "date" : 1662, "text" : "Fermat states his principle of least time", "picture" : "Pierre_de_Fermat" } ] speical_dates = [2016] + [ obj["date"] for obj in dated_events ] centuries = range(1600, 2100, 100) timeline = NumberLine( numerical_radius = 300, number_at_center = 1800, unit_length_to_spatial_width = SPACE_WIDTH/100, tick_frequency = 10, numbers_with_elongated_ticks = centuries ) timeline.add_numbers(*centuries) centers = [ Point(timeline.number_to_point(year)) for year in speical_dates ] timeline.add(*centers) timeline.shift(-centers[0].get_center()) self.add(timeline) self.dither() run_times = iter([3, 1]) for point, event in zip(centers[1:], dated_events): self.play(ApplyMethod( timeline.shift, -point.get_center(), run_time = run_times.next() )) picture = ImageMobject(event["picture"], invert = False) picture.scale_to_fit_width(2) picture.to_corner(UP+RIGHT) event_mob = TextMobject(event["text"]) event_mob.shift(2*LEFT+2*UP) date_mob = TexMobject(str(event["date"])) date_mob.scale(0.5) date_mob.shift(0.6*UP) line = Line(event_mob.get_bottom(), 0.2*UP) self.play( ShimmerIn(event_mob), ShowCreation(line), ShimmerIn(date_mob) ) self.play(FadeIn(picture)) self.dither(3) self.play(*map(FadeOut, [event_mob, date_mob, line, picture]))
def construct(self): tweets = [ ImageMobject("tweet%d" % x, invert=False) for x in range(1, 4) ] for tweet in tweets: tweet.scale(0.4) tweets[0].to_corner(UP + LEFT) tweets[1].next_to(tweets[0], RIGHT, aligned_edge=UP) tweets[2].next_to(tweets[1], DOWN) self.play(GrowFromCenter(tweets[0])) for x in 1, 2: self.play(Transform(Point(tweets[x - 1].get_center()), tweets[x]), Animation(tweets[x - 1])) self.dither()
def construct(self): low_res = ImageMobject("low_resolution_lion", invert=False) high_res = ImageMobject("Lion", invert=False) grid = get_grid().scale(0.8) for mob in low_res, high_res: mob.replace(grid, stretch=True) side_brace = Brace(low_res, LEFT) top_brace = Brace(low_res, UP) top_words = TextMobject("256 Px", size="\\normal") side_words = top_words.copy().rotate(np.pi / 2) top_words.next_to(top_brace, UP) side_words.next_to(side_brace, LEFT) self.add(high_res) self.dither() self.play(DelayByOrder(Transform(high_res, low_res))) self.dither() self.play(GrowFromCenter(top_brace), GrowFromCenter(side_brace), ShimmerIn(top_words), ShimmerIn(side_words)) self.dither() for mob in grid, high_res: mob.sort_points(np.linalg.norm) self.play(DelayByOrder(Transform(high_res, grid))) self.dither()
def construct(self): words = TextMobject("Yet another bit of Mark Levi cleverness") words.to_edge(UP) levi = ImageMobject("Mark_Levi", invert=False) levi.scale_to_fit_width(6) levi.show() self.add(levi) self.play(ShimmerIn(words)) self.wait(2)
def construct(self): newton, johann = [ ImageMobject(name, invert=False).scale(0.5) for name in "Newton", "Johann_Bernoulli2" ] greater_than = TexMobject(">") newton.next_to(greater_than, RIGHT) johann.next_to(greater_than, LEFT) self.add(johann, greater_than, newton) for i in range(2): kwargs = {"path_func": counterclockwise_path(), "run_time": 2} self.play( ApplyMethod(newton.replace, johann, **kwargs), ApplyMethod(johann.replace, newton, **kwargs), ) self.wait()
def construct(self): johann, fermat = [ ImageMobject(name, invert=False) for name in "Johann_Bernoulli2", "Pierre_de_Fermat" ] johann.scale(0.2) johann.to_corner(DOWN + LEFT) bubble = ThoughtBubble(initial_width=12) bubble.stretch_to_fit_height(6) bubble.pin_to(johann) bubble.shift(DOWN) bubble.add_content(fermat) fermat.scale_in_place(0.4) self.add(johann, bubble) self.wait() self.play(FadeIn(fermat)) self.wait()
def construct(self): image = ImageMobject("lion", invert=False) image.scale(0.5) image.shift(2 * LEFT) self.add(image) for vect, num in zip([DOWN, RIGHT], [1, 2]): brace = Brace(image, vect) words_mob = TextMobject("Dimension %d" % num) words_mob.next_to(image, vect, buff=1) self.play(Transform(Point(brace.get_center()), brace), ShimmerIn(words_mob), run_time=2) self.dither()
def construct(self): logo = ImageMobject("LogoGeneration", invert=False) name_mob = TextMobject("3Blue1Brown").center() name_mob.highlight("grey") name_mob.shift(2 * DOWN) self.add(name_mob, logo) new_text = TextMobject(["with ", "Steven Strogatz"]) new_text.next_to(name_mob, DOWN) self.play(*[ShimmerIn(part) for part in new_text.split()]) self.dither() with_word, steve = new_text.split() steve_copy = steve.copy().center().to_edge(UP) # logo.sort_points(lambda p : -np.linalg.norm(p)) sort_by_color(logo) self.play(Transform(steve, steve_copy), DelayByOrder(Transform(logo, Point())), FadeOut(with_word), FadeOut(name_mob), run_time=3)
def four_billion_earths(self): self.create_four_billion_copies(3, self.get_earth()) milky_way = ImageMobject("milky_way") milky_way.scale_to_fit_height(3) milky_way.to_edge(LEFT, buff=0) milky_way.shift(DOWN) n_stars_estimate = TextMobject("100 to 400 \\\\ billion stars") n_stars_estimate.next_to(milky_way, RIGHT) n_stars_estimate.shift(UP) earth, h_line, denom = self.get_fraction(3, self.get_earth(), self.get_galaxy()) self.revert_to_original_skipping_status() self.play(FadeIn(milky_way)) self.play(Write(n_stars_estimate)) self.dither() self.play( LaggedStart( Indicate, self.group_of_four_billion_things, rate_func=there_and_back, lag_ratio=0.2, run_time=3, )) self.dither() self.play( ReplacementTransform(self.group_of_four_billion_things, VGroup(earth)), ShowCreation(h_line), FadeIn(denom), self.four_billions[3].restore, FadeOut(milky_way), FadeOut(n_stars_estimate), ) self.dither()
def four_billion_earths(self): self.create_four_billion_copies( 3, self.get_earth() ) milky_way = ImageMobject("milky_way") milky_way.scale_to_fit_height(3) milky_way.to_edge(LEFT, buff = 0) milky_way.shift(DOWN) n_stars_estimate = TextMobject("100 to 400 \\\\ billion stars") n_stars_estimate.next_to(milky_way, RIGHT) n_stars_estimate.shift(UP) earth, h_line, denom = self.get_fraction( 3, self.get_earth(), self.get_galaxy() ) self.revert_to_original_skipping_status() self.play(FadeIn(milky_way)) self.play(Write(n_stars_estimate)) self.dither() self.play(LaggedStart( Indicate, self.group_of_four_billion_things, rate_func = there_and_back, lag_ratio = 0.2, run_time = 3, )) self.dither() self.play( ReplacementTransform( self.group_of_four_billion_things, VGroup(earth) ), ShowCreation(h_line), FadeIn(denom), self.four_billions[3].restore, FadeOut(milky_way), FadeOut(n_stars_estimate), ) self.dither()
def construct(self): morty = Mortimer(mode = "happy") keith = Keith(mode = "dance_kick") keith_image = ImageMobject("keith_schwarz", invert = False) # keith_image = Rectangle() keith_image.scale_to_fit_height(2*SPACE_HEIGHT - 2) keith_image.next_to(ORIGIN, LEFT) keith.move_to(keith_image, DOWN+RIGHT) morty.next_to(keith, buff = LARGE_BUFF, aligned_edge = DOWN) morty.make_eye_contact(keith) bubble = keith.get_bubble("speech") bubble.write("Check this out...") bubble.resize_to_content() bubble.pin_to(keith) VGroup(bubble, bubble.content).shift(DOWN) title = TextMobject("Keith Schwarz (Computer scientist)") title.to_edge(UP) self.add(keith_image, morty) self.play(Write(title)) self.play(FadeIn(keith, run_time = 2)) self.play(FadeOut(keith_image), Animation(keith)) self.play(Blink(morty)) self.play( keith.change_mode, "speaking", keith.scale_to_fit_height, morty.get_height(), keith.next_to, morty, LEFT, LARGE_BUFF, run_time = 1.5 ) self.play( ShowCreation(bubble), Write(bubble.content) ) self.play( morty.change_mode, "pondering", morty.look_at, bubble ) self.play(Blink(keith)) self.dither()
def construct(self): image = ImageMobject(os.path.join(RESOURCE_DIR, "dalembert_zoom")) image.scale_to_fit_width(2 * SPACE_WIDTH - 1) image.to_edge(UP, buff=MED_SMALL_BUFF) image.fade(0.15) rect = Rectangle( width=12, height=0.5, stroke_width=0, fill_opacity=0.3, fill_color=GREEN, ) rect.insert_n_anchor_points(20) rect.apply_function( lambda p: np.array([p[0], p[1] - 0.005 * p[0]**2, p[2]])) rect.rotate(0.012 * TAU) rect.move_to(image) rect.shift(0.15 * DOWN) words = TextMobject( "``Let", "$\\pi$", "be the", "circumference", "of a circle whose", "radius = 1''", ) words.highlight_by_tex_to_color_map({ "circumference": YELLOW, "radius": GREEN, }) words.next_to(image, DOWN) pi = words.get_part_by_tex("\\pi").copy() terms, generate_anims1, generate_anims2 = get_circle_drawing_terms( radius=1, positioning_func=lambda circ: circ.next_to(words, DOWN, buff=1.25)) circle, radius, one, decimal = terms unwrapped_perimeter = Line(ORIGIN, TAU * RIGHT) unwrapped_perimeter.match_style(circle) unwrapped_perimeter.next_to(circle, DOWN) brace = Brace(unwrapped_perimeter, UP, buff=SMALL_BUFF) perimeter = TexMobject( "\\pi\\epsilon\\rho\\iota\\mu\\epsilon\\tau\\rho\\text{o}\\varsigma", "\\text{ (perimeter)}", "=") perimeter.next_to(brace, UP, submobject_to_align=perimeter[1], buff=SMALL_BUFF) perimeter[0][0].highlight(GREEN) self.play(FadeInFromDown(image)) self.play(Write(words), GrowFromPoint(rect, rect.point_from_proportion(0.9))) self.wait() self.play(*generate_anims1()) self.play(*generate_anims2()) self.play(terms.shift, UP) self.play(pi.scale, 2, pi.shift, DOWN, pi.highlight, GREEN) self.wait() self.play( GrowFromCenter(brace), circle.set_stroke, YELLOW, 1, ReplacementTransform(circle.copy(), unwrapped_perimeter), decimal.scale, 1.25, decimal.next_to, perimeter[-1].get_right(), RIGHT, ReplacementTransform(pi, perimeter[0][0]), Write(perimeter), ) self.wait()
def construct(self): clock = Circle(radius=2, color=WHITE) clock.add(Dot(ORIGIN)) ticks = Mobject(*[ Line(1.8 * vect, 2 * vect, color=GREY) for vect in compass_directions(12) ]) clock.add(ticks) hour_hand = Line(ORIGIN, UP) minute_hand = Line(ORIGIN, 1.5 * UP) clock.add(hour_hand, minute_hand) clock.to_corner(UP + RIGHT) hour_hand.get_center = lambda: clock.get_center() minute_hand.get_center = lambda: clock.get_center() solution = ImageMobject("Newton_brachistochrone_solution2", use_cache=False) solution.stroke_width = 3 solution.highlight(GREY) solution.scale_to_fit_width(5) solution.to_corner(UP + RIGHT) newton = ImageMobject("Old_Newton", invert=False) newton.scale(0.8) phil_trans = TextMobject("Philosophical Transactions") rect = Rectangle(height=6, width=4.5, color=WHITE) rect.to_corner(UP + RIGHT) rect.shift(DOWN) phil_trans.scale_to_fit_width(0.8 * rect.get_width()) phil_trans.next_to(Point(rect.get_top()), DOWN) new_solution = solution.copy() new_solution.scale_to_fit_width(phil_trans.get_width()) new_solution.next_to(phil_trans, DOWN, buff=1) not_newton = TextMobject("-Totally not by Newton") not_newton.scale_to_fit_width(2.5) not_newton.next_to(new_solution, DOWN, aligned_edge=RIGHT) phil_trans.add(rect) newton_complaint = TextMobject([ "``I do not love to be", " \\emph{dunned} ", "and teased by foreigners''" ], size="\\small") newton_complaint.to_edge(UP, buff=0.2) dunned = newton_complaint.split()[1] dunned.highlight() dunned_def = TextMobject( "(old timey term for making \\\\ demands on someone)") dunned_def.scale(0.7) dunned_def.next_to(phil_trans, LEFT) dunned_def.shift(2 * UP) dunned_arrow = Arrow(dunned_def, dunned) johann = ImageMobject("Johann_Bernoulli2", invert=False) johann.scale(0.4) johann.to_edge(LEFT) johann.shift(DOWN) johann_quote = TextMobject("``I recognize the lion by his claw''") johann_quote.next_to(johann, UP, aligned_edge=LEFT) self.play(ApplyMethod(newton.to_edge, LEFT)) self.play(ShowCreation(clock)) kwargs = {"axis": OUT, "rate_func": smooth} self.play(Rotating(hour_hand, radians=-2 * np.pi, **kwargs), Rotating(minute_hand, radians=-12 * 2 * np.pi, **kwargs), run_time=5) self.wait() self.clear() self.add(newton) clock.ingest_submobjects() self.play(Transform(clock, solution)) self.remove(clock) self.add(solution) self.wait() self.play(FadeIn(phil_trans), Transform(solution, new_solution)) self.wait() self.play(ShimmerIn(not_newton)) phil_trans.add(solution, not_newton) self.wait() self.play(*map(ShimmerIn, newton_complaint.split())) self.wait() self.play(ShimmerIn(dunned_def), ShowCreation(dunned_arrow)) self.wait() self.remove(dunned_def, dunned_arrow) self.play(FadeOut(newton_complaint)) self.remove(newton_complaint) self.play(FadeOut(newton), GrowFromCenter(johann)) self.remove(newton) self.wait() self.play(ShimmerIn(johann_quote)) self.wait()
def construct(self): self.add_title() title = self.title basel_screen = ScreenRectangle(height=2.35) basel_screen.next_to(title, DOWN) watch_basel = TextMobject( "One such actual piece of math", "(quite pretty!)", ) watch_basel[0].highlight(YELLOW) watch_basel.next_to(basel_screen, DOWN, submobject_to_align=watch_basel[0]) self.add(watch_basel) # self.add(basel_screen) line = DashedLine(SPACE_WIDTH * LEFT, SPACE_WIDTH * RIGHT) line.next_to(watch_basel, DOWN) self.add(line) plushie_square = Square(side_length=2) plushie_square.to_corner(DOWN + LEFT, buff=MED_LARGE_BUFF) plushie_square.shift(UP) plushie_words = TextMobject( "Plushie pi \\\\ creatures \\\\ now available.", alignment="") plushie_words.next_to(plushie_square, RIGHT) self.add(plushie_words) # self.add(plushie_square) instagram_line = TextMobject("randy\\_the\\_pi") instagram_logo = ImageMobject("instagram_logo") instagram_logo.match_height(instagram_line) instagram_logo.next_to(instagram_line, LEFT, SMALL_BUFF) instagram = Group(instagram_logo, instagram_line) instagram.next_to(line, DOWN) instagram.shift(SPACE_WIDTH * RIGHT / 2) self.add(instagram) pictures = Group(*[ ImageMobject("randy/randy_%s" % name) for name in [ "science", "cooking", "in_a_can", "sandwhich", "lab", "fractal", "flowers", "group", "labcoat", "tennis", ] ]) for i, picture in enumerate(pictures): picture.scale_to_fit_height(2) picture.next_to(instagram, DOWN, aligned_edge=RIGHT) if i % 3 != 0: picture.next_to(last_picture, LEFT, buff=0) self.play(FadeIn(picture, run_time=2)) last_picture = picture
def construct(self): clock = Circle(radius = 2, color = WHITE) clock.add(Dot(ORIGIN)) ticks = Mobject(*[ Line(1.8*vect, 2*vect, color = GREY) for vect in compass_directions(12) ]) clock.add(ticks) hour_hand = Line(ORIGIN, UP) minute_hand = Line(ORIGIN, 1.5*UP) clock.add(hour_hand, minute_hand) clock.to_corner(UP+RIGHT) hour_hand.get_center = lambda : clock.get_center() minute_hand.get_center = lambda : clock.get_center() solution = ImageMobject( "Newton_brachistochrone_solution2", use_cache = False ) solution.stroke_width = 3 solution.highlight(GREY) solution.scale_to_fit_width(5) solution.to_corner(UP+RIGHT) newton = ImageMobject("Old_Newton", invert = False) newton.scale(0.8) phil_trans = TextMobject("Philosophical Transactions") rect = Rectangle(height = 6, width = 4.5, color = WHITE) rect.to_corner(UP+RIGHT) rect.shift(DOWN) phil_trans.scale_to_fit_width(0.8*rect.get_width()) phil_trans.next_to(Point(rect.get_top()), DOWN) new_solution = solution.copy() new_solution.scale_to_fit_width(phil_trans.get_width()) new_solution.next_to(phil_trans, DOWN, buff = 1) not_newton = TextMobject("-Totally not by Newton") not_newton.scale_to_fit_width(2.5) not_newton.next_to(new_solution, DOWN, aligned_edge = RIGHT) phil_trans.add(rect) newton_complaint = TextMobject([ "``I do not love to be", " \\emph{dunned} ", "and teased by foreigners''" ], size = "\\small") newton_complaint.to_edge(UP, buff = 0.2) dunned = newton_complaint.split()[1] dunned.highlight() dunned_def = TextMobject("(old timey term for making \\\\ demands on someone)") dunned_def.scale(0.7) dunned_def.next_to(phil_trans, LEFT) dunned_def.shift(2*UP) dunned_arrow = Arrow(dunned_def, dunned) johann = ImageMobject("Johann_Bernoulli2", invert = False) johann.scale(0.4) johann.to_edge(LEFT) johann.shift(DOWN) johann_quote = TextMobject("``I recognize the lion by his claw''") johann_quote.next_to(johann, UP, aligned_edge = LEFT) self.play(ApplyMethod(newton.to_edge, LEFT)) self.play(ShowCreation(clock)) kwargs = { "axis" : OUT, "rate_func" : smooth } self.play( Rotating(hour_hand, radians = -2*np.pi, **kwargs), Rotating(minute_hand, radians = -12*2*np.pi, **kwargs), run_time = 5 ) self.dither() self.clear() self.add(newton) clock.ingest_submobjects() self.play(Transform(clock, solution)) self.remove(clock) self.add(solution) self.dither() self.play( FadeIn(phil_trans), Transform(solution, new_solution) ) self.dither() self.play(ShimmerIn(not_newton)) phil_trans.add(solution, not_newton) self.dither() self.play(*map(ShimmerIn, newton_complaint.split())) self.dither() self.play( ShimmerIn(dunned_def), ShowCreation(dunned_arrow) ) self.dither() self.remove(dunned_def, dunned_arrow) self.play(FadeOut(newton_complaint)) self.remove(newton_complaint) self.play( FadeOut(newton), GrowFromCenter(johann) ) self.remove(newton) self.dither() self.play(ShimmerIn(johann_quote)) self.dither()
def construct(self): names = [ "Johann_Bernoulli2", "Jacob_Bernoulli", "Gottfried_Wilhelm_von_Leibniz", "Newton" ] guys = [ ImageMobject(name, invert = False) for name in names ] johann = guys[0] johann.scale(0.8) pensive_johann = johann.copy() pensive_johann.scale(0.25) pensive_johann.to_corner(DOWN+LEFT) comparitive_johann = johann.copy() template = Square(side_length = 2) comparitive_johann.replace(template) comparitive_johann.shift(UP+LEFT) greater_than = TexMobject(">") greater_than.next_to(comparitive_johann) for guy, name in zip(guys, names)[1:]: guy.replace(template) guy.next_to(greater_than) name_mob = TextMobject(name.replace("_", " ")) name_mob.scale(0.5) name_mob.next_to(guy, DOWN) guy.name_mob = name_mob guy.sort_points(lambda p : np.dot(p, DOWN+RIGHT)) bubble = ThoughtBubble(initial_width = 12) bubble.stretch_to_fit_height(6) bubble.ingest_submobjects() bubble.pin_to(pensive_johann) bubble.shift(DOWN) point = Point(johann.get_corner(UP+RIGHT)) upper_point = Point(comparitive_johann.get_corner(UP+RIGHT)) lightbulb = ImageMobject("Lightbulb", invert = False) lightbulb.scale(0.1) lightbulb.sort_points(np.linalg.norm) lightbulb.next_to(upper_point, RIGHT) self.add(johann) self.dither() self.play( Transform(johann, pensive_johann), Transform(point, bubble), run_time = 2 ) self.remove(point) self.add(bubble) weakling = guys[1] self.play( FadeIn(comparitive_johann), ShowCreation(greater_than), FadeIn(weakling) ) self.dither(2) for guy in guys[2:]: self.play(DelayByOrder(Transform( weakling, upper_point ))) self.play( FadeIn(guy), ShimmerIn(guy.name_mob) ) self.dither(3) self.remove(guy.name_mob) weakling = guy self.play(FadeOut(weakling), FadeOut(greater_than)) self.play(ShowCreation(lightbulb)) self.dither() self.play(FadeOut(comparitive_johann), FadeOut(lightbulb)) self.play(ApplyMethod( Mobject(johann, bubble).scale, 10, run_time = 3 ))
def get_image(name): return ImageMobject(os.path.join(RESOURCE_DIR, name))