def __init__(self, mobject1, mobject2, run_time=DEFAULT_TRANSFORM_RUN_TIME, interpolation_function=straight_path, black_out_extra_points=False, *args, **kwargs): self.interpolation_function = interpolation_function count1, count2 = mobject1.get_num_points(), mobject2.get_num_points() if count2 == 0: mobject2 = Point((SPACE_WIDTH, SPACE_HEIGHT, 0)) count2 = mobject2.get_num_points() Mobject.align_data(mobject1, mobject2) Animation.__init__(self, mobject1, run_time=run_time, *args, **kwargs) self.ending_mobject = mobject2 self.mobject.SHOULD_BUFF_POINTS = \ mobject1.SHOULD_BUFF_POINTS and mobject2.SHOULD_BUFF_POINTS self.reference_mobjects.append(mobject2) self.name += "To" + str(mobject2) if black_out_extra_points and count2 < count1: #Ensure redundant pixels fade to black indices = np.arange(0, count1 - 1, float(count1) / count2).astype('int') temp = np.zeros(mobject2.points.shape) temp[indices] = mobject2.rgbs[indices] mobject2.rgbs = temp self.non_redundant_m2_indices = indices
def __init__(self, mobject1, mobject2, run_time = DEFAULT_TRANSFORM_RUN_TIME, interpolation_function = straight_path, black_out_extra_points = False, *args, **kwargs): self.interpolation_function = interpolation_function count1, count2 = mobject1.get_num_points(), mobject2.get_num_points() if count2 == 0: mobject2 = Point((SPACE_WIDTH, SPACE_HEIGHT, 0)) count2 = mobject2.get_num_points() Mobject.align_data(mobject1, mobject2) Animation.__init__(self, mobject1, run_time = run_time, *args, **kwargs) self.ending_mobject = mobject2 self.mobject.SHOULD_BUFF_POINTS = \ mobject1.SHOULD_BUFF_POINTS and mobject2.SHOULD_BUFF_POINTS self.reference_mobjects.append(mobject2) self.name += "To" + str(mobject2) if black_out_extra_points and count2 < count1: #Ensure redundant pixels fade to black indices = np.arange( 0, count1-1, float(count1) / count2 ).astype('int') temp = np.zeros(mobject2.points.shape) temp[indices] = mobject2.rgbs[indices] mobject2.rgbs = temp self.non_redundant_m2_indices = indices
def construct(self): curve = PeanoCurve(order=5) curve.stretch_to_fit_width(2 * SPACE_WIDTH) curve.stretch_to_fit_height(2 * SPACE_HEIGHT) curve_start = curve.copy() curve_start.apply_over_attr_arrays(lambda arr: arr[:200]) time_line = get_time_line() time_line.shift(-time_line.number_to_point(2000)) self.add(time_line) self.play( ApplyMethod(time_line.shift, -time_line.number_to_point(1900), run_time=3)) brace = Brace( Mobject( Point(time_line.number_to_point(1865)), Point(time_line.number_to_point(1888)), ), UP) words = TextMobject(""" Cantor drives himself (and the \\\\ mathematical community at large) \\\\ crazy with research on infinity. """) words.next_to(brace, UP) self.play(GrowFromCenter(brace), ShimmerIn(words)) self.dither() self.play(Transform(time_line, curve_start), FadeOut(brace), FadeOut(words)) self.play(ShowCreation(curve, run_time=5, rate_func=None)) self.dither()
def __init__(self, mobject, point, **kwargs): digest_config(self, kwargs) target = mobject.copy() point_mob = Point(point) if self.point_color: point_mob.highlight(self.point_color) mobject.replace(point_mob) mobject.highlight(point_mob.get_color()) Transform.__init__(self, mobject, target, **kwargs)
def label_jump(self): jump_points = Mobject(Point(self.spiril1.points[-1]), Point(self.spiril2.points[0])) self.brace = Brace(jump_points, RIGHT) self.jump = TextMobject("Jump") self.jump.next_to(self.brace, RIGHT) self.play(GrowFromCenter(self.brace), ShimmerIn(self.jump)) self.dither() self.remove(self.brace, self.jump)
def construct(self): start_words = TextMobject([ "``", "Space Filling", "Curve ''", ]).to_edge(TOP, buff = 0.25) quote, space_filling, curve_quote = start_words.copy().split() curve_quote.shift( space_filling.get_left()-\ curve_quote.get_left() ) space_filling = Point(space_filling.get_center()) end_words = Mobject(*[ quote, space_filling, curve_quote ]).center().to_edge(TOP, buff = 0.25) space_filling_fractal = TextMobject(""" ``Space Filling Fractal'' """).to_edge(UP) curve = HilbertCurve(order = 2).shift(DOWN) fine_curve = HilbertCurve(order = 8) fine_curve.replace(curve) dots = Mobject(*[ Dot( curve.points[n*curve.get_num_points()/15], color = YELLOW_C ) for n in range(1, 15) if n not in [4, 11] ]) start_words.shift(2*(UP+LEFT)) self.play( ApplyMethod(start_words.shift, 2*(DOWN+RIGHT)) ) self.wait() self.play(Transform(start_words, end_words)) self.wait() self.play(ShowCreation(curve)) self.wait() self.play(ShowCreation( dots, run_time = 3, )) self.wait() self.clear() self.play(ShowCreation(fine_curve, run_time = 5)) self.wait() self.play(ShimmerIn(space_filling_fractal)) self.wait()
def construct(self): start_words = TextMobject([ "``", "Space Filling", "Curve ''", ]).to_edge(TOP, buff = 0.25) quote, space_filling, curve_quote = start_words.copy().split() curve_quote.shift( space_filling.get_left()-\ curve_quote.get_left() ) space_filling = Point(space_filling.get_center()) end_words = Mobject(*[ quote, space_filling, curve_quote ]).center().to_edge(TOP, buff = 0.25) space_filling_fractal = TextMobject(""" ``Space Filling Fractal'' """).to_edge(UP) curve = HilbertCurve(order = 2).shift(DOWN) fine_curve = HilbertCurve(order = 8) fine_curve.replace(curve) dots = Mobject(*[ Dot( curve.points[n*curve.get_num_points()/15], color = YELLOW_C ) for n in range(1, 15) if n not in [4, 11] ]) start_words.shift(2*(UP+LEFT)) self.play( ApplyMethod(start_words.shift, 2*(DOWN+RIGHT)) ) self.dither() self.play(Transform(start_words, end_words)) self.dither() self.play(ShowCreation(curve)) self.dither() self.play(ShowCreation( dots, run_time = 3, )) self.dither() self.clear() self.play(ShowCreation(fine_curve, run_time = 5)) self.dither() self.play(ShimmerIn(space_filling_fractal)) self.dither()
def construct(self): words = TextMobject("Would this actually work?") grid = get_grid() grid.scale_to_fit_width(6) grid.to_edge(LEFT) freq_line = get_freq_line() freq_line.scale_to_fit_width(6) freq_line.center().to_edge(RIGHT) mapping = Mobject(grid, freq_line, Arrow(grid, freq_line)) mapping.ingest_sub_mobjects() lower_left = Point().to_corner(DOWN + LEFT, buff=0) lower_right = Point().to_corner(DOWN + RIGHT, buff=0) self.add(words) self.dither() self.play(Transform(words, lower_right), Transform(lower_left, mapping)) self.dither()
def construct(self): val = 0.3 text = TextMobject([ "PHC", "$_n", "(", "%3.1f"%val, ")$", " has a ", "limit point ", "as $n \\to \\infty$" ]) func_parts = text.copy().split()[:5] Mobject(*func_parts).center().to_edge(UP) num_str, val_str = func_parts[1], func_parts[3] curve = UnitInterval() curve.sort_points(lambda p : p[0]) dot = Dot().shift(curve.number_to_point(val)) arrow = Arrow(val_str, dot, buff = 0.1) curve.add_numbers(0, 1) self.play(ShowCreation(curve)) self.play( ShimmerIn(val_str), ShowCreation(arrow), ShowCreation(dot) ) self.wait() self.play( FadeOut(arrow), *[ FadeIn(func_parts[i]) for i in 0, 1, 2, 4 ] ) for num in range(2,9): new_curve = HilbertCurve(order = num) new_curve.scale(0.8) new_dot = Dot(new_curve.points[int(val*new_curve.get_num_points())]) new_num_str = TexMobject(str(num)).replace(num_str) self.play( Transform(curve, new_curve), Transform(dot, new_dot), Transform(num_str, new_num_str) ) self.wait() text.to_edge(UP) text_parts = text.split() for index in 1, -1: text_parts[index].highlight() starters = Mobject(*func_parts + [ Point(mob.get_center(), stroke_width=1) for mob in text_parts[5:] ]) self.play(Transform(starters, text)) arrow = Arrow(text_parts[-2].get_bottom(), dot, buff = 0.1) self.play(ShowCreation(arrow)) self.wait()
def construct(self): mathy, bubble = get_mathy_and_bubble() squiggle_mouth = mathy.mouth.copy() squiggle_mouth.apply_function( lambda (x, y, z) : (x, y+0.02*np.sin(50*x), z) ) bubble.ingest_submobjects() bubble.write("Why not use a Hilbert curve \\textinterrobang ") words1 = bubble.content bubble.write("So, it's not one curve but an infinite family of curves \\dots") words2 = bubble.content bubble.write("Well, no, it \\emph{is} just one thing, but I need \\\\ \ to tell you about a certain infinite family first.") words3 = bubble.content description = TextMobject("Mathematician friend", size = "\\small") description.next_to(mathy, buff = 2) arrow = Arrow(description, mathy) self.add(mathy) self.play( ShowCreation(arrow), ShimmerIn(description) ) self.dither() point = Point(bubble.get_tip()) self.play( Transform(point, bubble), ) self.remove(point) self.add(bubble) self.play(ShimmerIn(words1)) self.dither() self.remove(description, arrow) self.play( Transform(mathy.mouth, squiggle_mouth), ApplyMethod(mathy.arm.wag, 0.2*RIGHT, LEFT), ) self.remove(words1) self.add(words2) self.dither(2) self.remove(words2) self.add(words3) self.dither(2) self.play( ApplyPointwiseFunction( lambda p : 15*p/np.linalg.norm(p), bubble ), ApplyMethod(mathy.shift, 5*(DOWN+LEFT)), FadeOut(words3), run_time = 3 )
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): mathy, bubble = get_mathy_and_bubble() bubble.stretch_to_fit_width(4) mathy.to_corner(DOWN + LEFT) bubble.pin_to(mathy) bubble.shift(LEFT) morty = Mortimer() morty.to_corner(DOWN + RIGHT) morty_bubble = SpeechBubble() morty_bubble.stretch_to_fit_width(4) morty_bubble.pin_to(morty) bubble.write(""" Did you know a curve \\\\ can fill all space? """) morty_bubble.write("Who cares?") self.add(mathy, morty) for bub, buddy in [(bubble, mathy), (morty_bubble, morty)]: self.play(Transform(Point(bub.get_tip()), bub)) self.play(ShimmerIn(bub.content)) self.play( ApplyMethod(buddy.blink, rate_func=squish_rate_func(there_and_back)))
def __init__(self, mobject, point, **kwargs): target = mobject.copy() point_mob = Point(point) mobject.replace(point_mob) mobject.highlight(point_mob.get_color()) Transform.__init__(self, mobject, target, **kwargs)
def __init__(self, mobject, **kwargs): Transform.__init__(self, mobject, Point(mobject.get_center()), **kwargs)
def __init__(self, mobject, **kwargs): target = mobject.copy() point = Point(mobject.get_center()) mobject.replace(point) mobject.highlight(point.get_color()) Transform.__init__(self, mobject, target, **kwargs)