diff --git a/manimlib/continual_animation/update.py b/manimlib/continual_animation/update.py index c4c55195..4b7dffd5 100644 --- a/manimlib/continual_animation/update.py +++ b/manimlib/continual_animation/update.py @@ -3,28 +3,6 @@ from manimlib.continual_animation.continual_animation import ContinualAnimation from manimlib.mobject.value_tracker import ValueTracker -class ContinualUpdate(ContinualAnimation): - CONFIG = { - "function_depends_on_dt": False - } - - def __init__(self, mobject, func, **kwargs): - self.func = func - ContinualAnimation.__init__(self, mobject, **kwargs) - - def update_mobject(self, dt): - if self.function_depends_on_dt: - self.func(self.mobject, dt) - else: - self.func(self.mobject) - - -class ContinualUpdateFromTimeFunc(ContinualUpdate): - CONFIG = { - "function_depends_on_dt": True - } - - class ContinualMaintainPositionRelativeTo(ContinualAnimation): # TODO: Possibly reimplement using CycleAnimation? def __init__(self, mobject, tracked_mobject, **kwargs): diff --git a/old_projects/WindingNumber_G.py b/old_projects/WindingNumber_G.py index c643095c..85ecd39d 100644 --- a/old_projects/WindingNumber_G.py +++ b/old_projects/WindingNumber_G.py @@ -968,7 +968,7 @@ class IntroduceInputOutputScene(InputOutputScene): return dots def get_output_dot_continual_update(self, input_dot, output_dot): - return ContinualUpdate( + return Mobject.add_updater( output_dot, lambda od : od.move_to(self.point_function(input_dot.get_center())) ) @@ -996,7 +996,7 @@ class IntroduceVectorField(IntroduceInputOutputScene): color = out_dot.get_color(), ) out_vector.set_stroke(BLACK, 1) - continual_out_vector_update = ContinualUpdate( + continual_out_vector_update = Mobject.add_updater( out_vector, lambda ov : ov.put_start_and_end_on( output_plane.coords_to_point(0, 0), out_dot.get_center(), @@ -1008,7 +1008,7 @@ class IntroduceVectorField(IntroduceInputOutputScene): Transform(in_vector, out_vector).update(1) in_vector.scale(0.5) in_vector.shift(in_dot.get_center() - in_vector.get_start()) - continual_in_vector_update = ContinualUpdate( + continual_in_vector_update = Mobject.add_updater( in_vector, update_in_vector ) continual_updates = [ @@ -2308,7 +2308,7 @@ class TransitionFromPathsToBoundaries(ColorMappedObjectsScene): #Setup dot, arrow and label dot = self.dot = Dot(radius = 0.1) dot.set_stroke(WHITE, self.dot_stroke_width) - update_dot_color = ContinualUpdate( + update_dot_color = Mobject.add_updater( dot, lambda d : d.set_fill( get_output_color(), self.dot_fill_opacity @@ -2330,7 +2330,7 @@ class TransitionFromPathsToBoundaries(ColorMappedObjectsScene): arrow.scale(arrow_length/arrow.get_length()) arrow.shift(dot.get_center() - arrow.get_start()) return arrow - update_arrow = ContinualUpdate(arrow, arrow_update_func) + update_arrow = Mobject.add_updater(arrow, arrow_update_func) if self.include_walkers: self.add(update_arrow, update_dot_color, label_upadte) @@ -2797,27 +2797,27 @@ class WindingNumbersInInputOutputContext(PathContainingZero): out_loop = in_loop.copy() out_loop.match_background_image_file(self.output_coloring) - update_out_loop = ContinualUpdate( + update_out_loop = Mobject.add_updater( out_loop, lambda m : m.set_points(in_loop.points).apply_function(self.point_function) ) # self.add(update_out_loop) in_dot = Dot(radius = 0.04) - update_in_dot = ContinualUpdate( + update_in_dot = Mobject.add_updater( in_dot, lambda d : d.move_to(in_loop.point_from_proportion(1)) ) self.add(update_in_dot) out_arrow = Arrow(LEFT, RIGHT) - update_out_arrow = ContinualUpdate( + update_out_arrow = Mobject.add_updater( out_arrow, lambda a : a.put_start_and_end_on( self.output_plane.coords_to_point(0, 0), out_loop.point_from_proportion(1) ) ) - update_out_arrow_color = ContinualUpdate( + update_out_arrow_color = Mobject.add_updater( out_arrow, lambda a : a.set_color(rev_to_color(a.get_angle()/TAU)) ) @@ -2975,7 +2975,7 @@ class TickingClock(Scene): line.set_color(rev_to_color(rev)) for line in lines: - self.add(ContinualUpdate(line, update_line)) + self.add(Mobject.add_updater(line, update_line)) run_time = self.run_time self.play(ClockPassesTime( diff --git a/old_projects/alt_calc.py b/old_projects/alt_calc.py index 6d57206d..3fd0bb1a 100644 --- a/old_projects/alt_calc.py +++ b/old_projects/alt_calc.py @@ -701,21 +701,18 @@ class StartingCalc101(PiCreatureScene): t_tracker = ValueTracker(0) group = VGroup(spring, weight) group.continual_animations = [ - ContinualUpdateFromTimeFunc( - t_tracker, + t_tracker.add_udpater( lambda tracker, dt: tracker.set_value( tracker.get_value() + dt ) ), - ContinualUpdate( - spring, + spring.add_updater( lambda s: s.stretch_to_fit_height( 1.5 + 0.5 * np.cos(3 * t_tracker.get_value()), about_edge=UP ) ), - ContinualUpdate( - weight, + weight.add_updater( lambda w: w.move_to(spring.points[-1]) ) ] @@ -934,10 +931,8 @@ class ChangingVectorField(Scene): self.add(ContinualGrowValue(time_tracker)) vectors = self.get_vectors() - self.add(ContinualUpdate( - vectors, - lambda vs: self.update_vectors(vs) - )) + vectors.add_updater(self.update_vectors) + self.add(vectors) self.wait(self.wait_time) def get_vectors(self): @@ -1111,36 +1106,36 @@ class StandardDerivativeVisual(GraphScene): triangle.set_stroke(width=0) triangle.scale(0.1) - input_triangle_update = ContinualUpdate( - input_triangle, lambda m: m.move_to(get_x_point(), UP) + input_triangle_update = input_tracker.add_updater( + lambda m: m.move_to(get_x_point(), UP) ) - output_triangle_update = ContinualUpdate( - output_triangle, lambda m: m.move_to(get_y_point(), RIGHT) + output_triangle_update = output_triangle.add_updater( + lambda m: m.move_to(get_y_point(), RIGHT) ) x_label = TexMobject("x") - x_label_update = ContinualUpdate( + x_label_update = Mobject.add_updater( x_label, lambda m: m.next_to(input_triangle, DOWN, SMALL_BUFF) ) output_label = TexMobject("f(x)") - output_label_update = ContinualUpdate( + output_label_update = Mobject.add_updater( output_label, lambda m: m.next_to( output_triangle, LEFT, SMALL_BUFF) ) v_line = get_v_line() - v_line_update = ContinualUpdate( + v_line_update = Mobject.add_updater( v_line, lambda vl: Transform(vl, get_v_line()).update(1) ) h_line = get_h_line() - h_line_update = ContinualUpdate( + h_line_update = Mobject.add_updater( h_line, lambda hl: Transform(hl, get_h_line()).update(1) ) graph_dot = Dot(color=YELLOW) - graph_dot_update = ContinualUpdate( + graph_dot_update = Mobject.add_updater( graph_dot, lambda m: m.move_to(get_graph_point()) ) @@ -1192,7 +1187,7 @@ class StandardDerivativeVisual(GraphScene): ).secant_line slope_line = get_slope_line() - slope_line_update = ContinualUpdate( + slope_line_update = Mobject.add_updater( slope_line, lambda sg: Transform(sg, get_slope_line()).update(1) ) @@ -1203,7 +1198,7 @@ class StandardDerivativeVisual(GraphScene): "\\frac{df}{dx}(x) =", "\\text{Slope}", "=" ) deriv_label.get_part_by_tex("Slope").match_color(slope_line) - deriv_label_update = ContinualUpdate( + deriv_label_update = Mobject.add_updater( deriv_label, position_deriv_label ) diff --git a/old_projects/basel/basel2.py b/old_projects/basel/basel2.py index efe3da14..5b3560c4 100644 --- a/old_projects/basel/basel2.py +++ b/old_projects/basel/basel2.py @@ -1322,13 +1322,13 @@ class IntroduceScreen(Scene): def rotate_screen(self): self.add( - ContinualUpdate( + Mobject.add_updater( self.light_source, lambda m : m.update() ), ) self.add( - ContinualUpdate( + Mobject.add_updater( self.angle_indicator, lambda m : m.set_stroke(width = 0).set_fill(opacity = 1) ) @@ -1629,8 +1629,8 @@ class InverseSquareLaw(ThreeDScene): def update_spotlight(spotlight): spotlight.update_sectors() - spotlight_update = ContinualUpdate(spotlight, update_spotlight) - shadow_update = ContinualUpdate( + spotlight_update = Mobject.add_updater(spotlight, update_spotlight) + shadow_update = Mobject.add_updater( shadow, lambda m : light_source.update_shadow() ) @@ -1642,7 +1642,7 @@ class InverseSquareLaw(ThreeDScene): distance = get_norm(screen.get_reference_point() - source_point) light_indicator.set_intensity(1.0/(distance/unit_distance)**2) light_indicator.next_to(morty, UP, MED_LARGE_BUFF) - light_indicator_update = ContinualUpdate( + light_indicator_update = Mobject.add_updater( light_indicator, update_light_indicator ) light_indicator_update.update(0) @@ -1964,7 +1964,7 @@ class ManipulateLightsourceSetups(PiCreatureScene): self.add(light_source) self.add_foreground_mobjects(morty, bubble, light_indicator) - self.add(ContinualUpdate(light_indicator, update_light_indicator)) + self.add(Mobject.add_updater(light_indicator, update_light_indicator)) self.play( ApplyMethod( light_source.shift, 0.66*unit_distance*LEFT, @@ -2165,7 +2165,7 @@ class TwoLightSourcesScene(ManipulateLightsourceSetups): d_indensity *= ls.ambient_light.submobjects[1].get_fill_opacity() intensity += d_indensity indicator.set_intensity(intensity) - indicator_update_anim = ContinualUpdate(indicator, update_indicator) + indicator_update_anim = Mobject.add_updater(indicator, update_indicator) new_indicator = indicator.copy() new_indicator.light_source = lsC @@ -2611,7 +2611,7 @@ class IPTScene(TwoLightSourcesScene, ZoomedScene): ) spotlights = VGroup(spotlight_a, spotlight_b) - spotlights_update_anim = ContinualUpdate( + spotlights_update_anim = Mobject.add_updater( spotlights, update_spotlights ) @@ -2759,7 +2759,7 @@ class DiameterTheorem(TeacherStudentsScene): circle.get_left(), circle.get_right(), point.get_center(), circle.get_left(), ]) - triangle_update_anim = ContinualUpdate( + triangle_update_anim = Mobject.add_updater( triangle, update_triangle ) triangle_update_anim.update(0) @@ -2824,7 +2824,7 @@ class InscribedeAngleThreorem(TeacherStudentsScene): circle.point_from_proportion(1./8), point.get_center(), ]) - shape_update_anim = ContinualUpdate( + shape_update_anim = Mobject.add_updater( shape, update_shape ) shape_update_anim.update(0) @@ -3852,7 +3852,7 @@ class ThinkBackToHowAmazingThisIs(ThreeDScene): z = self.camera.rotation_mobject.get_center()[2] decimal.set_height(0.07*z) decimal.move_to(0.7*z*UP) - scale_decimal = ContinualUpdate(decimal, update_decimal) + scale_decimal = Mobject.add_updater(decimal, update_decimal) self.add(number_line, *dot_pairs) diff --git a/old_projects/dandelin.py b/old_projects/dandelin.py index bd2d288e..13911c5f 100644 --- a/old_projects/dandelin.py +++ b/old_projects/dandelin.py @@ -546,7 +546,7 @@ class EccentricityInThumbtackCase(ShowArrayOfEccentricities): focus_distance.set_color(GREEN) focus_distance.next_to(inner_brace_update.mobject, DOWN, SMALL_BUFF) focus_distance.add_to_back(focus_distance.copy().set_stroke(BLACK, 5)) - focus_distance_update = ContinualUpdate( + focus_distance_update = Mobject.add_updater( focus_distance, lambda m: m.set_width( inner_brace_update.mobject.get_width(), @@ -565,7 +565,7 @@ class EccentricityInThumbtackCase(ShowArrayOfEccentricities): fraction.set_color_by_tex("Diameter", RED) fraction.move_to(2 * UP) fraction.to_edge(RIGHT, buff=MED_LARGE_BUFF) - numerator_update = ContinualUpdate( + numerator_update = Mobject.add_updater( numerator, lambda m: m.set_width(focus_distance.get_width()).next_to( fraction[1], UP, MED_SMALL_BUFF @@ -630,7 +630,7 @@ class EccentricityInThumbtackCase(ShowArrayOfEccentricities): thumbtack.move_to(focus, DR) return thumbtacks - return ContinualUpdate(thumbtacks, update_thumbtacks) + return Mobject.add_updater(thumbtacks, update_thumbtacks) def get_ellipse_point_update(self, ellipse): dot = Dot(color=RED) @@ -651,10 +651,10 @@ class EccentricityInThumbtackCase(ShowArrayOfEccentricities): line.put_start_and_end_on(focus, Q) return lines - return ContinualUpdate(lines, update_lines) + return Mobject.add_updater(lines, update_lines) def get_focus_to_focus_line_update(self, ellipse): - return ContinualUpdate( + return Mobject.add_updater( Line(LEFT, RIGHT, color=WHITE), lambda m: m.put_start_and_end_on(*self.get_foci(ellipse)) ) @@ -662,7 +662,7 @@ class EccentricityInThumbtackCase(ShowArrayOfEccentricities): def get_focus_line_to_focus_line_brace_update(self, line): brace = Brace(Line(LEFT, RIGHT)) brace.add_to_back(brace.copy().set_stroke(BLACK, 5)) - return ContinualUpdate( + return Mobject.add_updater( brace, lambda b: b.match_width(line, stretch=True).next_to( line, DOWN, buff=SMALL_BUFF @@ -1613,7 +1613,7 @@ class EllipseLengthsLinedUp(EccentricityInThumbtackCase): lines.arrange(DOWN, buff=0) lines.next_to(arrow, RIGHT) h_line.move_to(lines[0].get_bottom()) - lines_animation = ContinualUpdate( + lines_animation = Mobject.add_updater( lines, update_lines ) diff --git a/old_projects/div_curl.py b/old_projects/div_curl.py index 396e0783..06ef6393 100644 --- a/old_projects/div_curl.py +++ b/old_projects/div_curl.py @@ -651,7 +651,7 @@ class ShowWritingTrajectory(TeacherStudentsScene): s0.target_center += dt * LEFT * 0.5 s0.move_to(s0.target_center) - self.add(ContinualUpdateFromTimeFunc(s0, update_s0)) + self.add(Mobject.add_updater(s0, update_s0)) self.change_student_modes("tired", "horrified", "sad") self.play(s0.look, LEFT) self.wait(4) @@ -1594,8 +1594,8 @@ class ChangingElectricField(Scene): particle.shift(particle.velocity * dt) self.add( - ContinualUpdate(vector_field, update_vector_field), - ContinualUpdateFromTimeFunc(particles, update_particles), + Mobject.add_updater(vector_field, update_vector_field), + Mobject.add_updater(particles, update_particles), ) self.wait(20) @@ -1829,7 +1829,7 @@ class DefineDivergence(ChangingElectricField): "\\text{div} \\, \\textbf{F}(x, y) = " ) div_tex.add_background_rectangle() - div_tex_update = ContinualUpdate( + div_tex_update = Mobject.add_updater( div_tex, lambda m: m.next_to(circle, UP, SMALL_BUFF) ) @@ -2074,7 +2074,7 @@ class DivergenceAsNewFunction(Scene): ) self.add(func_tex, rhs) - # self.add(ContinualUpdate( + # self.add(Mobject.add_updater( # rhs, lambda m: m.next_to(func_tex, RIGHT) # )) @@ -2098,7 +2098,7 @@ class DivergenceAsNewFunction(Scene): out_vect.move_to(rhs) out_vect.set_fill(opacity=0) self.play(out_vect.restore) - self.out_vect_update = ContinualUpdate( + self.out_vect_update = Mobject.add_updater( out_vect, lambda ov: Transform(ov, get_out_vect()).update(1) ) @@ -2106,7 +2106,7 @@ class DivergenceAsNewFunction(Scene): self.add(self.out_vect_update) self.add(out_x_update, out_y_update) - self.add(ContinualUpdate( + self.add(Mobject.add_updater( VGroup(out_x, out_y), lambda m: m.match_style(out_vect) )) @@ -2175,7 +2175,7 @@ class DivergenceAsNewFunction(Scene): )) vector_ring = get_vector_ring() - vector_ring_update = ContinualUpdate( + vector_ring_update = Mobject.add_updater( vector_ring, lambda vr: Transform(vr, get_vector_ring()).update(1) ) @@ -2203,7 +2203,7 @@ class DivergenceAsNewFunction(Scene): ) # This line is a dumb hack around a Scene bug self.add(*[ - ContinualUpdate( + Mobject.add_updater( mob, lambda m: m.set_fill(None, 0) ) for mob in (out_x, out_y) @@ -2570,7 +2570,7 @@ class ShowCurlAtVariousPoints(IntroduceCurl): dot = Dot() circle = Circle(radius=0.25, color=WHITE) circle.move_to(dot) - circle_update = ContinualUpdate( + circle_update = Mobject.add_updater( circle, lambda m: m.move_to(dot) ) @@ -2579,7 +2579,7 @@ class ShowCurlAtVariousPoints(IntroduceCurl): "\\text{curl} \\, \\textbf{F}(x, y) = " ) curl_tex.add_background_rectangle(buff=0.025) - curl_tex_update = ContinualUpdate( + curl_tex_update = Mobject.add_updater( curl_tex, lambda m: m.next_to(circle, UP, SMALL_BUFF) ) @@ -3087,10 +3087,10 @@ class ShowTwoPopulations(Scene): return update - self.add(ContinualUpdate( + self.add(Mobject.add_updater( foxes, get_updater(get_num_foxes) )) - self.add(ContinualUpdate( + self.add(Mobject.add_updater( rabbits, get_updater(get_num_rabbits) )) @@ -3113,7 +3113,7 @@ class ShowTwoPopulations(Scene): )) for count in num_foxes, num_rabbits: - self.add(ContinualUpdate( + self.add(Mobject.add_updater( count, self.update_count_color, )) @@ -3264,7 +3264,7 @@ class PhaseSpaceOfPopulationModel(ShowTwoPopulations, PiCreatureScene, MovingCam position_update_func=lambda m: m.move_to(tens[i]) ) coord_pair.add_background_rectangle() - coord_pair_update = ContinualUpdate( + coord_pair_update = Mobject.add_updater( coord_pair, lambda m: m.next_to(dot, UR, SMALL_BUFF) ) pop_sizes_updates = [get_pop_size_update(i) for i in (0, 1)] @@ -3825,7 +3825,7 @@ class ShowCrossProduct(ShowDotProduct): fill_opacity=0.2, ) - self.add(ContinualUpdate( + self.add(Mobject.add_updater( square, lambda s: s.set_points_as_corners([ ORIGIN, @@ -4035,7 +4035,7 @@ class DivergenceTinyNudgesView(MovingCameraScene): moving_step_vector.get_end(), moving_step_vector.get_end() + diff, ) - self.moving_diff_vector_update = ContinualUpdate( + self.moving_diff_vector_update = Mobject.add_updater( moving_diff_vector, update_moving_diff_vector ) diff --git a/old_projects/fourier.py b/old_projects/fourier.py index 47601333..4a71f3ef 100644 --- a/old_projects/fourier.py +++ b/old_projects/fourier.py @@ -2666,7 +2666,7 @@ class WriteComplexExponentialExpression(DrawFrequencyPlot): v_line.put_start_and_end_on( plane.coords_to_point(x, 0), point ) - lines_update_anim = ContinualUpdate(lines, lines_update) + lines_update_anim = Mobject.add_updater(lines, lines_update) lines_update_anim.update(0) self.add(lines_update_anim) @@ -2764,12 +2764,12 @@ class WriteComplexExponentialExpression(DrawFrequencyPlot): exp_base.get_corner(UP+RIGHT), DOWN+LEFT ) ) - exp_base_update = ContinualUpdate( + exp_base_update = Mobject.add_updater( exp_base, lambda e : e.move_to(get_circle_point( scalar = 1.1, t_shift = 0.01*TAU )) ) - vector_update = ContinualUpdate( + vector_update = Mobject.add_updater( vector, lambda v : v.put_start_and_end_on( plane.number_to_point(0), get_circle_point() ) @@ -4007,7 +4007,7 @@ class ShowUncertaintyPrinciple(Scene): )) self.wait(2) self.add(*[ - ContinualUpdate(graph, get_update_func(axes)) + Mobject.add_updater(graph, get_update_func(axes)) for graph, axes in [(top_graph, top_axes), (bottom_graph, bottom_axes)] ]) for factor in factors: diff --git a/old_projects/lost_lecture.py b/old_projects/lost_lecture.py index 46aefa17..f0bab45a 100644 --- a/old_projects/lost_lecture.py +++ b/old_projects/lost_lecture.py @@ -755,7 +755,7 @@ class AskAboutEllipses(TheMotionOfPlanets): l2.put_start_and_end_on(f2, P) return lines - animation = ContinualUpdate( + animation = Mobject.add_updater( lines, update_lines ) self.add(animation) @@ -790,7 +790,7 @@ class AskAboutEllipses(TheMotionOfPlanets): ) Transform(measurement, new_decimal).update(1) - radius_measurement_animation = ContinualUpdate( + radius_measurement_animation = Mobject.add_updater( radius_measurement, update_radial_measurement ) @@ -948,7 +948,7 @@ class AskAboutEllipses(TheMotionOfPlanets): arrow.shift( radial_line.get_end() - arrow.get_start() ) - force_arrow_animation = ContinualUpdate( + force_arrow_animation = Mobject.add_updater( force_arrow, update_force_arrow ) @@ -957,7 +957,7 @@ class AskAboutEllipses(TheMotionOfPlanets): def get_radial_line_and_update(self, comet): line = Line(LEFT, RIGHT) line.set_stroke(LIGHT_GREY, 1) - line_update = ContinualUpdate( + line_update = Mobject.add_updater( line, lambda l: l.put_start_and_end_on( self.sun.get_center(), comet.get_center(), @@ -1212,7 +1212,7 @@ class ShowEllipseDefiningProperty(Scene): dot = Dot() dot.scale(0.5) position_tracker = ValueTracker(0.125) - dot_update = ContinualUpdate( + dot_update = Mobject.add_updater( dot, lambda d: d.move_to( self.ellipse.point_from_proportion( @@ -1381,7 +1381,7 @@ class ShowEllipseDefiningProperty(Scene): focus, focal_sum_point.get_center() ) lines[1].rotate(np.pi) - lines_update_animation = ContinualUpdate( + lines_update_animation = Mobject.add_updater( lines, update_lines ) return lines, lines_update_animation @@ -1416,7 +1416,7 @@ class ShowEllipseDefiningProperty(Scene): ) label.submobjects = list(new_decimal.submobjects) - distance_labels_animation = ContinualUpdate( + distance_labels_animation = Mobject.add_updater( distance_labels, update_distance_labels ) @@ -1799,7 +1799,7 @@ class ProveEllipse(ShowEmergingEllipse, ShowEllipseDefiningProperty): if line.get_end()[0] > line.get_start()[0]: vect = label.get_center() - line.get_center() label.shift(-2 * vect) - distance_label_shift_update_animation = ContinualUpdate( + distance_label_shift_update_animation = Mobject.add_updater( self.distance_labels[0], distance_label_shift_update ) @@ -1810,7 +1810,7 @@ class ProveEllipse(ShowEmergingEllipse, ShowEllipseDefiningProperty): # Define QP line QP_line = Line(LEFT, RIGHT) QP_line.match_style(self.focal_lines) - QP_line_update = ContinualUpdate( + QP_line_update = Mobject.add_updater( QP_line, lambda l: l.put_start_and_end_on( Q_dot.get_center(), P_dot.get_center(), ) @@ -1818,7 +1818,7 @@ class ProveEllipse(ShowEmergingEllipse, ShowEllipseDefiningProperty): QE_line = Line(LEFT, RIGHT) QE_line.set_stroke(YELLOW, 3) - QE_line_update = ContinualUpdate( + QE_line_update = Mobject.add_updater( QE_line, lambda l: l.put_start_and_end_on( Q_dot.get_center(), self.get_eccentricity_point() @@ -1848,7 +1848,7 @@ class ProveEllipse(ShowEmergingEllipse, ShowEllipseDefiningProperty): label.rotate(angle, about_point=Q_dot.get_center()) return label - distance_label_rotate_update_animation = ContinualUpdate( + distance_label_rotate_update_animation = Mobject.add_updater( self.distance_labels[0], distance_label_rotate_update ) @@ -2083,7 +2083,7 @@ class ProveEllipse(ShowEmergingEllipse, ShowEllipseDefiningProperty): else: line.set_stroke(WHITE, 1) - lines_update_animation = ContinualUpdate( + lines_update_animation = Mobject.add_updater( lines, update_lines ) @@ -2364,7 +2364,7 @@ class NonEllipticalKeplersLaw(KeplersSecondLaw): arrow, arrow_update = self.get_force_arrow_and_update( comet ) - alt_arrow_update = ContinualUpdate( + alt_arrow_update = Mobject.add_updater( arrow, lambda a: a.scale( 1.0 / a.get_length(), about_point=a.get_start() @@ -2971,7 +2971,7 @@ class IntroduceShapeOfVelocities(AskAboutEllipses, MovingCameraScene): ) Transform(vector, new_vector).update(1) - moving_vector_animation = ContinualUpdate( + moving_vector_animation = Mobject.add_updater( moving_vector, update_moving_vector ) return moving_vector, moving_vector_animation diff --git a/old_projects/nn/part2.py b/old_projects/nn/part2.py index 9e1eeaee..766ec3a3 100644 --- a/old_projects/nn/part2.py +++ b/old_projects/nn/part2.py @@ -569,7 +569,7 @@ class FunctionMinmization(GraphScene): dot.move_to(self.input_to_graph_point(x, graph)) self.add(*[ - ContinualUpdate(dot, update_dot) + Mobject.add_updater(dot, update_dot) for dot in dots ]) self.wait(10) @@ -1752,8 +1752,8 @@ class SingleVariableCostFunction(GraphScene): new_ball.point = point balls.add(new_ball) updates += [ - ContinualUpdate(point, update_point), - ContinualUpdate(new_ball, update_ball) + Mobject.add_updater(point, update_point), + Mobject.add_updater(new_ball, update_ball) ] balls.set_color_by_gradient(BLUE, GREEN) diff --git a/old_projects/pi_day.py b/old_projects/pi_day.py index 81b53226..d3894ae0 100644 --- a/old_projects/pi_day.py +++ b/old_projects/pi_day.py @@ -695,7 +695,7 @@ class UsingTheta(Scene): theta = TexMobject("\\theta", "=") theta[0].match_color(arc) theta.add_background_rectangle() - update_theta = ContinualUpdate( + update_theta = Mobject.add_updater( theta, lambda m : m.shift( rotate_vector(0.9*RIGHT, radius.get_angle()/2) \ - m[1][0].get_center() diff --git a/old_projects/quaternions.py b/old_projects/quaternions.py index ebc7b97b..fdef69a7 100644 --- a/old_projects/quaternions.py +++ b/old_projects/quaternions.py @@ -5808,7 +5808,7 @@ class ShowArbitraryMultiplication(ShowMultiplicationBy135Example): t.set_value(normalize(t.get_value())) # for tracker in q_tracker, m_tracker: - # self.add(ContinualUpdate(tracker, normalize_tracker)) + # self.add(Mobject.add_updater(tracker, normalize_tracker)) updates = [ UpdateFromFunc(tracker, normalize_tracker) for tracker in (q_tracker, m_tracker) diff --git a/old_projects/uncertainty.py b/old_projects/uncertainty.py index 00c752b4..da5cb2a8 100644 --- a/old_projects/uncertainty.py +++ b/old_projects/uncertainty.py @@ -294,7 +294,7 @@ class MentionUncertaintyPrinciple(TeacherStudentsScene): brace.next_to(gdw, vect) text.next_to(brace, vect, buff = SMALL_BUFF) group.set_color(color) - return ContinualUpdate(group, update_group) + return Mobject.add_updater(group, update_group) dot_brace_anim = get_brace_text_group_update( dot_cloud.gaussian_distribution_wrapper, @@ -1655,7 +1655,7 @@ class MentionDopplerRadar(TeacherStudentsScene): plane.flip() pulse = RadarPulse(dish, plane) look_at_anims = [ - ContinualUpdate( + Mobject.add_updater( pi, lambda pi : pi.look_at(pulse.mobject) ) for pi in self.get_pi_creatures() @@ -1757,7 +1757,7 @@ class IntroduceDopplerRadar(Scene): run_time = 0.97*axes.x_max ) ) - randy_look_at = ContinualUpdate( + randy_look_at = Mobject.add_updater( randy, lambda pi : pi.look_at(pulse.mobject) ) axes_anim = ContinualAnimation(axes) @@ -2808,11 +2808,11 @@ class SummarizeFourierTradeoffForDoppler(Scene): top_graphs = get_top_graphs() bottom_graphs = get_bottom_graphs() - update_top_graphs = ContinualUpdate( + update_top_graphs = Mobject.add_updater( top_graphs, lambda g : Transform(g, get_top_graphs()).update(1) ) - update_bottom_graphs = ContinualUpdate( + update_bottom_graphs = Mobject.add_updater( bottom_graphs, lambda g : Transform(g, get_bottom_graphs()).update(1) ) @@ -3308,7 +3308,7 @@ class SortOfDopplerEffect(PiCreatureScene): ]) return wave = get_wave() - wave_update = ContinualUpdate( + wave_update = Mobject.add_updater( wave, lambda w : Transform(w, get_wave()).update(1) ) @@ -3318,7 +3318,7 @@ class SortOfDopplerEffect(PiCreatureScene): rect_movement = rect randy = self.pi_creature - randy_look_at = ContinualUpdate( + randy_look_at = Mobject.add_updater( randy, lambda r : r.look_at(rect) ) @@ -3328,7 +3328,7 @@ class SortOfDopplerEffect(PiCreatureScene): ref_frame2 = TextMobject("Reference frame 2") ref_frame2.next_to(rect, UP) # ref_frame2.set_fill(opacity = 0) - ref_frame2_follow = ContinualUpdate( + ref_frame2_follow = Mobject.add_updater( ref_frame2, lambda m : m.next_to(rect, UP) ) ref_frame_1_continual_anim = ContinualAnimation(ref_frame1) @@ -3452,7 +3452,7 @@ class HangingWeightsScene(MovingCameraScene): d_height = A*np.cos(TAU*f*t - k*x) new_spring = get_spring(spring.alpha, 2+d_height) Transform(spring, new_spring).update(1) - spring_update_anim = ContinualUpdate(springs, update_springs) + spring_update_anim = Mobject.add_updater(springs, update_springs) self.spring_update_anim = spring_update_anim spring_update_anim.update(0) @@ -3471,7 +3471,7 @@ class HangingWeightsScene(MovingCameraScene): weight.start_radius = 0.15 weight.target_radius = 0.25*mass #For future update weight.spring = spring - weight_anim = ContinualUpdate( + weight_anim = Mobject.add_updater( weight, lambda w : w.move_to(w.spring.get_bottom()) ) weight_anim.update(0) @@ -3615,7 +3615,7 @@ class HangingWeightsScene(MovingCameraScene): de_broglie.set_height(6) de_broglie.next_to(4*DOWN, DOWN) self.add( - ContinualUpdate( + Mobject.add_updater( randy, lambda m : m.next_to( rect.get_corner(DOWN+LEFT), UP+RIGHT, MED_LARGE_BUFF, ).look_at(weights) @@ -3663,7 +3663,7 @@ class HangingWeightsScene(MovingCameraScene): return mob.curr_anim.update(mob.curr_anim_time/mob.curr_anim.run_time) - return ContinualUpdateFromTimeFunc(mobject, update) + return Mobject.add_updater(mobject, update) class MinutPhysicsWrapper(Scene): def construct(self): @@ -4051,7 +4051,7 @@ class ProbabalisticDetection(FourierTransformOfWaveFunction): rect.save_state() rect.stretch(0, 0) - gdw_anim = ContinualUpdate( + gdw_anim = Mobject.add_updater( gdw, lambda m : m.set_width( 2.0/(self.a_tracker.get_value()**(0.5)) ).move_to(rect) @@ -4073,7 +4073,7 @@ class ProbabalisticDetection(FourierTransformOfWaveFunction): answer.submobjects = [yes] else: answer.submobjects = [no] - answer_anim = ContinualUpdate(answer, update_answer) + answer_anim = Mobject.add_updater(answer, update_answer) self.add(gdw_anim, particle) self.play( @@ -4289,13 +4289,13 @@ class ThinkOfHeisenbergUncertainty(PiCreatureScene): freq = 1 continual_anims = [ always_shift(time_tracker, direction = RIGHT, rate = 1), - ContinualUpdate( + Mobject.add_updater( dot_gdw, lambda d : d.set_width( (np.cos(freq*time_tracker.get_value()) + 1.1)/2 ) ), - ContinualUpdate( + Mobject.add_updater( vector_gdw, lambda d : d.set_width( (-np.cos(freq*time_tracker.get_value()) + 1.1)/2 diff --git a/old_projects/waves.py b/old_projects/waves.py index c399ba46..c3eab6ae 100644 --- a/old_projects/waves.py +++ b/old_projects/waves.py @@ -1209,10 +1209,10 @@ class ShowVectorEquation(Scene): ) brace.next_to(self.vector.get_center(), DOWN, SMALL_BUFF) return brace - moving_brace = ContinualUpdate( + moving_brace = Mobject.add_updater( Brace(Line(LEFT, RIGHT), DOWN), update_brace ) - moving_x_without_phi = ContinualUpdate( + moving_x_without_phi = Mobject.add_updater( x_without_phi.copy().add_background_rectangle(), lambda m : m.next_to(moving_brace.mobject, DOWN, SMALL_BUFF) ) @@ -1631,7 +1631,7 @@ class ShowTipToTailSum(ShowVectorEquation): self.v_oscillating_vector.A_vect = [0, 2, 0] self.v_oscillating_vector.update(0) - self.d_oscillating_vector = ContinualUpdate( + self.d_oscillating_vector = Mobject.add_updater( Vector(UP+RIGHT, color = E_COLOR), lambda v : v.put_start_and_end_on( ORIGIN, @@ -1706,8 +1706,8 @@ class ShowTipToTailSum(ShowVectorEquation): self.h_oscillating_vector, self.v_oscillating_vector, self.d_oscillating_vector, - ContinualUpdate(h_line, h_line.update), - ContinualUpdate(v_line, v_line.update), + Mobject.add_updater(h_line, h_line.update), + Mobject.add_updater(v_line, v_line.update), ) self.wait(4) @@ -2173,10 +2173,10 @@ class ShowPolarizingFilter(DirectionOfPolarizationScene): return update_decimal continual_updates = [ - ContinualUpdate( + Mobject.add_updater( A_x, generate_decimal_update(np.sin), ), - ContinualUpdate( + Mobject.add_updater( A_y, generate_decimal_update(np.cos), ), ]