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