def update_mobject(self, alpha): ApplyMethod.update_mobject(self, alpha) if alpha == 0: return radians = alpha * self.total_tire_radians for tire in self.mobject.get_tires(): tire.rotate_in_place(radians)
def move_camera(self, phi=None, theta=None, distance=None, gamma=None, frame_center=None, added_anims=[], **kwargs): anims = [] value_tracker_pairs = [ (phi, self.camera.phi_tracker), (theta, self.camera.theta_tracker), (distance, self.camera.distance_tracker), (gamma, self.camera.gamma_tracker), ] for value, tracker in value_tracker_pairs: if value is not None: anims.append(ApplyMethod(tracker.set_value, value, **kwargs)) if frame_center is not None: anims.append( ApplyMethod(self.camera.frame_center.move_to, frame_center)) is_camera_rotating = self.ambient_camera_rotation in self.continual_animations if is_camera_rotating: self.remove(self.ambient_camera_rotation) self.play(*anims + added_anims) if is_camera_rotating: self.add(self.ambient_camera_rotation)
def update_mobject(self, alpha): ApplyMethod.update_mobject(self, alpha) if alpha == 0: return radians = alpha * self.total_tire_radians for tire in self.mobject.get_tires(): tire.rotate_in_place(radians)
def construct(self): number_line = NumberLine( numerical_radius = 5, number_at_center = 5, leftmost_tick = 0, density = 2*DEFAULT_POINT_DENSITY_1D ) number_line.shift(2*RIGHT) number_line.add_numbers() number_line.scale(2) brace = Brace(Mobject( *number_line.submobjects[:2] )) self.add(number_line) for n in range(0, 10, 2): if n == 0: brace_anim = GrowFromCenter(brace) else: brace_anim = ApplyMethod(brace.shift, 2*RIGHT) self.play( ApplyMethod( number_line.highlight, RED, lambda p : p[0] > n-6.2 and p[0] < n-4 and p[1] > -0.4 ), brace_anim )
def __init__(self, car, target_point, **kwargs): ApplyMethod.__init__(self, car.move_to, target_point, **kwargs) displacement = self.target_mobject.get_right()-self.starting_mobject.get_right() distance = np.linalg.norm(displacement) if not self.moving_forward: distance *= -1 tire_radius = car.get_tires()[0].get_width()/2 self.total_tire_radians = -distance/tire_radius
def __init__(self, car, target_point, **kwargs): assert isinstance(car, Car) ApplyMethod.__init__(self, car.move_to, target_point, **kwargs) displacement = self.target_mobject.get_right() - self.starting_mobject.get_right() distance = np.linalg.norm(displacement) if not self.moving_forward: distance *= -1 tire_radius = car.get_tires()[0].get_width() / 2 self.total_tire_radians = -distance / tire_radius
def show_multiplication(self, num, **kwargs): if "path_func" not in kwargs: if num > 0: kwargs["path_func"] = straight_path else: kwargs["path_func"] = counterclockwise_path() self.play(*[ApplyMethod(self.number_line.stretch, num, 0, **kwargs)] + [ ApplyMethod(mob.shift, (num - 1) * mob.get_center()[0] * RIGHT, **kwargs) for mob in self.number_mobs ])
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 advance_cursor(self, cursor_depth=-1, initialize_depth=-1): """ Moves a cursor to the next block of equal level and initializes new cursors on the new block. """ if cursor_depth < 0: cursor_depth = len(self.cursor_indices) + cursor_depth # find parent block of cursor to advance cur_block = self.block_from_indices(self.cursor_indices, cursor_depth) # calculate index of the block to advance to new_index = self.cursor_indices[cursor_depth] + 1 if new_index > len(cur_block.submobjects) - 1: if cur_block.has_header(): new_index = self.get_child_idx(cur_block) else: new_index = 0 # remove old cursors and blocks anims = [] for cursor in self.cursors[cursor_depth + 1:]: anims.append(Uncreate(cursor)) self.cursors = self.cursors[:cursor_depth + 1] self.cursor_indices = self.cursor_indices[:cursor_depth + 1] self.cursor_indices[cursor_depth] = new_index # move cursor new_block = cur_block.submobjects[new_index] if new_block.has_header(): anims.append( ApplyMethod(self.cursors[cursor_depth].next_to, new_block[0], LEFT)) else: anims.append( ApplyMethod(self.cursors[cursor_depth].next_to, new_block[0], LEFT)) if new_block.has_header(): # add new blocks self.recurse(new_block, self.cursor_indices, initialize_depth=initialize_depth) # add new cursors anims.extend( self.place_cursors( indices=self.cursor_indices[cursor_depth + 1:], block=new_block, )) return anims
def construct(self): 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) arrow = Arrow(grid, freq_line) color1, color2 = YELLOW_C, RED square_length = 0.01 dot1 = Dot(color = color1) dot1.shift(3*RIGHT) dot2 = Dot(color = color2) dot2.shift(3.1*RIGHT) arrow1 = Arrow(2*RIGHT+UP, dot1, color = color1, buff = 0.1) arrow2 = Arrow(4*RIGHT+UP, dot2, color = color2, buff = 0.1) dot3, arrow3 = [ mob.copy().shift(5*LEFT+UP) for mob in dot1, arrow1 ] dot4, arrow4 = [ mob.copy().shift(5*LEFT+0.9*UP) for mob in dot2, arrow2 ] self.add(grid, freq_line, arrow) self.dither() self.play(ApplyMethod( arrow.rotate, np.pi, path_func = clockwise_path() )) self.dither() self.play(ShowCreation(arrow1)) self.add(dot1) self.play(ShowCreation(arrow2)) self.add(dot2) self.dither() self.remove(arrow1, arrow2) self.play( Transform(dot1, dot3), Transform(dot2, dot4) ) self.play( ApplyMethod(grid.fade, 0.8), Animation(Mobject(dot3, dot4)) ) self.play(ShowCreation(arrow3)) self.play(ShowCreation(arrow4)) self.dither()
def tex(self, latex): eq = TextMobject(latex) anims = [] anims.append(Write(eq)) for mobject in self.mobjects: anims.append(ApplyMethod(mobject.shift, 2 * UP)) self.play(*anims)
def construct(self): mathy, bubble = get_mathy_and_bubble() bubble.sort_points(lambda p: np.dot(p, UP + RIGHT)) self.add(mathy) self.dither() self.play( ApplyMethod(mathy.blink, rate_func=squish_rate_func(there_and_back))) self.dither() self.play(ShowCreation(bubble)) self.dither() self.play(ApplyMethod(mathy.shift, 3 * (DOWN + LEFT)), ApplyPointwiseFunction(lambda p: 15 * p / np.linalg.norm(p), bubble), run_time=3)
def construct(self): words = TextMobject("Order 3 Pseudo-Hilbert Curve") words.highlight(GREEN) words.to_edge(UP) grid4 = Mobject(Grid(2, 2), Grid(4, 4, point_thickness=2)) grid8 = Grid(8, 8, point_thickness=1) order_3_curve = HilbertCurve(order=3) mini_curves = [ HilbertCurve(order=2).scale(0.5).shift(1.5 * vect) for vect in [LEFT + DOWN, LEFT + UP, RIGHT + UP, RIGHT + DOWN] ] self.add(words, grid4) self.dither() self.play(ShowCreation(grid8)) self.dither() self.play(*map(GrowFromCenter, mini_curves)) self.dither() self.clear() self.add(words, grid8, *mini_curves) self.play(*[ ApplyMethod(curve.rotate_in_place, np.pi, axis) for curve, axis in [(mini_curves[0], UP + RIGHT), (mini_curves[3], UP + LEFT)] ]) self.play(ShowCreation(order_3_curve, run_time=5)) self.dither()
def increase_order(self): mini_curves = [ self.curve.copy().scale(0.5).shift(1.5*vect) for vect in [ LEFT+DOWN, LEFT+UP, RIGHT+UP, RIGHT+DOWN ] ] self.remove(self.curve) self.play( Transform(self.curve.copy(), mini_curves[0]) ) self.play(*[ GrowFromCenter(mini_curve) for mini_curve in mini_curves[1:] ]) self.dither() self.clear() self.add(*mini_curves) self.play(*[ ApplyMethod(curve.rotate_in_place, np.pi, axis) for curve, axis in [ (mini_curves[0], UP+RIGHT), (mini_curves[3], UP+LEFT) ] ]) self.curve = HilbertCurve(order = self.curve.order+1) self.play(ShowCreation(self.curve, run_time = 2)) self.remove(*mini_curves) self.dither()
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): start_curve = SnakeCurve(order = 6) end_curve = SnakeCurve(order = 7) start_dots, end_dots = [ Mobject(*[ Dot( curve.points[int(x*curve.get_num_points())], color = color ) for x, color in [ (0.202, GREEN), (0.48, BLUE), (0.7, RED) ] ]) for curve in start_curve, end_curve ] self.add(start_curve) self.dither() self.play( ShowCreation(start_dots, run_time = 2), ApplyMethod(start_curve.fade) ) end_curve.fade() self.play( Transform(start_curve, end_curve), Transform(start_dots, end_dots) ) self.dither()
def construct(self): curve = HilbertCurve(order=1) grid = Grid(2, 2, stroke_width=1) self.add(grid, curve) for order in range(2, 6): self.dither() new_grid = Grid(2**order, 2**order, stroke_width=1) self.play(ShowCreation(new_grid), Animation(curve)) self.remove(grid) grid = new_grid self.play(Transform(curve, HilbertCurve(order=order))) square = Square(side_length=6, color=WHITE) square.corner = Mobject1D() square.corner.add_line(3 * DOWN, ORIGIN) square.corner.add_line(ORIGIN, 3 * RIGHT) square.digest_mobject_attrs() square.scale(2**(-5)) square.corner.highlight( Color(rgb=curve.rgbs[curve.get_num_points() / 3])) square.shift( grid.get_corner(UP+LEFT)-\ square.get_corner(UP+LEFT) ) self.dither() self.play(FadeOut(grid), FadeOut(curve), FadeIn(square)) self.play(ApplyMethod(square.replace, grid)) self.dither()
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, pi_creature, *content, **kwargs): digest_config(self, kwargs) bubble = pi_creature.get_bubble("speech") bubble.write(*content) bubble.resize_to_content() bubble.pin_to(pi_creature) pi_creature.bubble = bubble AnimationGroup.__init__( self, ApplyMethod( pi_creature.change_mode, self.target_mode, **self.change_mode_kwargs ), ShowCreation( bubble, **self.bubble_creation_kwargs ), Write( bubble.content, **self.write_kwargs ), **kwargs )
def construct(self): words = TextMobject([ "One does not simply define the limit \\\\ \ of a sequence of", "curves", "\\dots" ]) top_words = TextMobject(["curves", "are functions"]).to_edge(UP) curves1 = words.split()[1] curves2 = top_words.split()[0] words.ingest_submobjects() number = TexMobject("0.27") pair = TexMobject("(0.53, 0.02)") pair.next_to(number, buff=2) arrow = Arrow(number, pair) Mobject(number, arrow, pair).center().shift(UP) number_line = UnitInterval() number_line.stretch_to_fit_width(5) number_line.to_edge(LEFT).shift(DOWN) grid = Grid(4, 4).scale(0.4) grid.next_to(number_line, buff=2) low_arrow = Arrow(number_line, grid) self.play(ShimmerIn(words)) self.dither() self.play(FadeOut(words), ApplyMethod(curves1.replace, curves2), ShimmerIn(top_words.split()[1])) self.dither() self.play(FadeIn(number)) self.play(ShowCreation(arrow)) self.play(FadeIn(pair)) self.dither() self.play(ShowCreation(number_line)) self.play(ShowCreation(low_arrow)) self.play(ShowCreation(grid)) self.dither()
def construct(self): grid = get_grid() grid.sort_points(np.linalg.norm) freq_line = get_freq_line() freq_line.sort_points(lambda p : p[0]) red, blue = Color(RED), Color(BLUE) freq_line.gradient_highlight(red, blue) colors = [ Color(rgb = interpolate( np.array(red.rgb), np.array(blue.rgb), alpha )) for alpha in np.arange(4)/3. ] string = Line(3*LEFT, 3*RIGHT, color = colors[1]) vibration = Vibrate(string) vibration_copy = vibration.copy() vibration_copy.mobject.stroke_width = 1 sub_vibrations = [ Vibrate( string.copy().shift((n-1)*UP).highlight(colors[n]), overtones = 1, spatial_period = 6./(n+1), temporal_period = 1./(n+1), amplitude = 0.5/(n+1) ) for n in range(4) ] words = TexMobject("&\\vdots \\\\ \\text{thousands }& \\text{of frequencies} \\\\ &\\vdots") words.to_edge(UP, buff = 0.1) self.add(grid) self.dither() self.play(DelayByOrder(ApplyMethod( grid.gradient_highlight, red, blue ))) self.play(Transform(grid, freq_line)) self.dither() self.play( ShimmerIn( words, rate_func = squish_rate_func(smooth, 0, 0.2) ), *sub_vibrations, run_time = 5 ) self.play( *[ TransformAnimations( sub_vib, vibration ) for sub_vib in sub_vibrations ]+[FadeOut(words)] ) self.clear() self.add(freq_line) self.play(vibration)
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.wait() 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.wait(2) for guy in guys[2:]: self.play(DelayByOrder(Transform(weakling, upper_point))) self.play(FadeIn(guy), ShimmerIn(guy.name_mob)) self.wait(3) self.remove(guy.name_mob) weakling = guy self.play(FadeOut(weakling), FadeOut(greater_than)) self.play(ShowCreation(lightbulb)) self.wait() self.play(FadeOut(comparitive_johann), FadeOut(lightbulb)) self.play(ApplyMethod(Mobject(johann, bubble).scale, 10, run_time=3))
def get_zoom_in_animation(self, run_time=2, **kwargs): frame = self.zoomed_camera.frame full_frame_height = self.camera.get_frame_height() full_frame_width = self.camera.get_frame_width() frame.save_state() frame.stretch_to_fit_width(full_frame_width) frame.stretch_to_fit_height(full_frame_height) frame.center() frame.set_stroke(width=0) return ApplyMethod(frame.restore, run_time=run_time, **kwargs)
def repeat_cursor_1(self, target_depth=-1): cursor = self.cursors[target_depth] anims = [ApplyMethod(cursor.shift, self.repeat_cursor_dist * LEFT)] # remove child cursors anims.append(Uncreate(Group(*self.cursors[target_depth + 1:]))) self.cursors = self.cursors[:target_depth + 1] self.cursor_indices = self.cursor_indices[:target_depth + 1] return anims
def __init__(self, pi_creature, **kwargs): assert hasattr(pi_creature, "bubble") digest_config(self, kwargs, locals()) AnimationGroup.__init__( self, ApplyMethod(pi_creature.change_mode, self.target_mode), FadeOut(pi_creature.bubble), FadeOut(pi_creature.bubble.content), )
def show_change_side_by_side(self): seed = TextMobject("Seed") seed.shift(3 * LEFT + 2 * DOWN) fractal = TextMobject("Fractal") fractal.shift(3 * RIGHT + 2 * DOWN) words = map(TextMobject, [ "A sharper angle results in a richer curve", "A more obtuse angle gives a sparser curve", "And as the angle approaches 0\\dots", "We have a new space-filling curve." ]) for text in words: text.to_edge(UP) sharper, duller, space_filling = [ CurveClass(order=1).shift(3 * LEFT) for CurveClass in SharperKoch, DullerKoch, SpaceFillingKoch ] shaper_f, duller_f, space_filling_f = [ CurveClass(order=self.max_order).shift(3 * RIGHT) for CurveClass in SharperKoch, DullerKoch, SpaceFillingKoch ] self.add(words[0]) left_curve = SharperKoch(order=1) right_curve = SharperKoch(order=1) self.play( Transform(left_curve, sharper), ApplyMethod(right_curve.shift, 3 * RIGHT), ) self.play( Transform(right_curve, SharperKoch(order=2).shift(3 * RIGHT)), ShimmerIn(seed), ShimmerIn(fractal)) for order in range(3, self.max_order): self.play( Transform(right_curve, SharperKoch(order=order).shift(3 * RIGHT))) self.remove(words[0]) self.add(words[1]) kwargs = { "run_time": 4, } self.play(Transform(left_curve, duller, **kwargs), Transform(right_curve, duller_f, **kwargs)) self.wait() kwargs["run_time"] = 7 kwargs["rate_func"] = None self.remove(words[1]) self.add(words[2]) self.play(Transform(left_curve, space_filling, **kwargs), Transform(right_curve, space_filling_f, **kwargs)) self.remove(words[2]) self.add(words[3]) self.wait()
def zoom_in_on(self, number, zoom_factor, run_time=2.0): unit_length_to_spatial_width = self.number_line.unit_length_to_spatial_width * zoom_factor radius = SPACE_WIDTH / unit_length_to_spatial_width tick_frequency = 10**(np.floor(np.log10(radius))) left_tick = tick_frequency * (np.ceil( (number - radius) / tick_frequency)) new_number_line = NumberLine( numerical_radius=radius, unit_length_to_spatial_width=unit_length_to_spatial_width, tick_frequency=tick_frequency, leftmost_tick=left_tick, number_at_center=number) new_displayed_numbers = new_number_line.default_numbers_to_display() new_number_mobs = new_number_line.get_number_mobjects( *new_displayed_numbers) transforms = [] additional_mobjects = [] squished_new_line = new_number_line.copy() squished_new_line.scale(1.0 / zoom_factor) squished_new_line.shift(self.number_line.number_to_point(number)) squished_new_line.points[:, 1] = self.number_line.number_to_point(0)[1] transforms.append(Transform(squished_new_line, new_number_line)) for mob, num in zip(new_number_mobs, new_displayed_numbers): point = Point(self.number_line.number_to_point(num)) point.shift(new_number_line.get_vertical_number_offset()) transforms.append(Transform(point, mob)) for mob in self.mobjects: if mob == self.number_line: new_mob = mob.copy() new_mob.shift(-self.number_line.number_to_point(number)) new_mob.stretch(zoom_factor, 0) transforms.append(Transform(mob, new_mob)) continue mob_center = mob.get_center() number_under_center = self.number_line.point_to_number(mob_center) new_point = new_number_line.number_to_point(number_under_center) new_point += mob_center[1] * UP if mob in self.number_mobs: transforms.append(Transform(mob, Point(new_point))) else: transforms.append( ApplyMethod(mob.shift, new_point - mob_center)) additional_mobjects.append(mob) line_to_hide_pixelation = Line(self.number_line.get_left(), self.number_line.get_right(), color=self.number_line.get_color()) self.add(line_to_hide_pixelation) self.play(*transforms, run_time=run_time) self.clear() self.number_line = new_number_line self.displayed_numbers = new_displayed_numbers self.number_mobs = new_number_mobs self.add(self.number_line, *self.number_mobs) self.add(*additional_mobjects)
def equivalence(self, left_mob, arrow, right_mob): self.clear() self.add(left_mob, arrow, right_mob) words = TextMobject("is equivalent to") words.shift(0.25 * LEFT) words.highlight(BLUE) new_left = left_mob.copy().shift(RIGHT) new_right = right_mob.copy() new_right.shift( (words.get_right()[0]-\ right_mob.get_left()[0]+\ 0.5 )*RIGHT ) for mob in arrow, words: mob.sort_points(np.linalg.norm) self.play(ApplyMethod(left_mob.shift, RIGHT), Transform(arrow, words), ApplyMethod(right_mob.to_edge, RIGHT)) self.wait()
def __init__(self, drunk, pos, total_time=1, turn_ratio=0.25): anims = [] if self.is_same_direction(drunk, pos): anims.append(ApplyMethod(drunk.step_on, pos, run_time=total_time)) else: turn_target = drunk.deepcopy().turn_around() move_target = turn_target.deepcopy().step_on(pos) ## TODO: This part is currently broken! anims.append( Succession( ApplyMethod(drunk.turn_around, run_time=turn_ratio * total_time), ApplyMethod(turn_target.step_on, pos, run_time=(1 - turn_ratio) * total_time), FadeOut(turn_target, run_time=0), Transform(drunk, move_target, run_time=0), )) drunk.change_direction() AnimationGroup.__init__(self, *anims)
def pose_question(self): infinity, rightarrow, N = TexMobject(["\\infty", "\\rightarrow", "N"]).scale(2).split() question_mark = TextMobject("?").scale(2) self.add(question_mark) self.dither() self.play(*[ShimmerIn(mob) for mob in infinity, rightarrow, N] + [ ApplyMethod(question_mark.next_to, rightarrow, UP), ]) self.dither()
def construct(self): axes = XYZAxes() axes.highlight(WHITE) plane = NumberPlane() vects = [ Arrow(point, point+(3./27)*(3*x**2-3*y**2)*OUT, color = MAROON_D) for x in range(-4, 5, 2) for y in range(-5, 5, 2) for point in [x*RIGHT + y*UP] ] everybody = Mobject(axes, plane, *vects) self.play(ApplyMethod( everybody.rotate, 0.9*np.pi/2, RIGHT )) self.dither() self.play(ApplyMethod( everybody.rotate, np.pi/2, run_time = 5 ))
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 __init__(self, pi_creature, **kwargs): ApplyMethod.__init__(self, pi_creature.blink, **kwargs)