Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Get rid of one_at_a_time

Grant Sandersonf9010f342168
diff --git a/manimlib/animation/creation.py b/manimlib/animation/creation.py
index 4398e4f80..f39a9741f 100644
--- a/manimlib/animation/creation.py
+++ b/manimlib/animation/creation.py
@@ -16,9 +16,13 @@ from manimlib.utils.rate_functions import smooth
class ShowPartial(Animation):
- def interpolate_submobject(self, submobject, starting_submobject, alpha):
- submobject.pointwise_become_partial(
- starting_submobject, *self.get_bounds(alpha)
+ """
+ Abstract class for ShowCreation and ShowPassingFlash
+ """
+
+ def interpolate_submobject(self, submob, start_submob, alpha):
+ submob.pointwise_become_partial(
+ start_submob, *self.get_bounds(alpha)
)
def get_bounds(self, alpha):
@@ -27,7 +31,7 @@ class ShowPartial(Animation):
class ShowCreation(ShowPartial):
CONFIG = {
- "submobject_mode": "one_at_a_time",
+ "lag_ratio": 1,
}
def get_bounds(self, alpha):
diff --git a/manimlib/scene/vector_space_scene.py b/manimlib/scene/vector_space_scene.py
index bba83f15a..e31ea7eec 100644
--- a/manimlib/scene/vector_space_scene.py
+++ b/manimlib/scene/vector_space_scene.py
@@ -49,14 +49,14 @@ class VectorScene(Scene):
def add_plane(self, animate=False, **kwargs):
plane = NumberPlane(**kwargs)
if animate:
- self.play(ShowCreation(plane, submobject_mode="lagged_start"))
+ self.play(ShowCreation(plane, lag_ratio=0.5))
self.add(plane)
return plane
def add_axes(self, animate=False, color=WHITE, **kwargs):
axes = Axes(color=color, tick_frequency=1)
if animate:
- self.play(ShowCreation(axes, submobject_mode="one_at_a_time"))
+ self.play(ShowCreation(axes))
self.add(axes)
return axes
diff --git a/old_projects/eoc/chapter1.py b/old_projects/eoc/chapter1.py
index cb65475f9..d65cfe42e 100644
--- a/old_projects/eoc/chapter1.py
+++ b/old_projects/eoc/chapter1.py
@@ -1796,7 +1796,7 @@ class ExampleIntegralProblems(PiCreatureScene, GraphScene):
MoveCar(car, end),
FadeIn(
ticks,
- submobject_mode = "one_at_a_time",
+ lag_ratio=1,
rate_func=linear,
),
ShowCreation(line),
diff --git a/old_projects/eoc/old_chapter1.py b/old_projects/eoc/old_chapter1.py
index 8ccd2a3fc..de79962be 100644
--- a/old_projects/eoc/old_chapter1.py
+++ b/old_projects/eoc/old_chapter1.py
@@ -1715,7 +1715,7 @@ class IntroduceConcentricRings(CircleScene):
self.play(
FadeIn(
VGroup(*rings[:-1]),
- submobject_mode = "one_at_a_time",
+ lag_ratio=1,
run_time = 5
),
Animation(foreground_group)
diff --git a/old_projects/eola/chapter0.py b/old_projects/eola/chapter0.py
index 3632cd5b4..bbdeec9d2 100644
--- a/old_projects/eola/chapter0.py
+++ b/old_projects/eola/chapter0.py
@@ -359,7 +359,7 @@ class NumericToComputations(Scene):
bottom.next_to(arrow, DOWN)
self.add(top)
- self.play(ShowCreation(arrow, submobject_mode = "one_at_a_time"))
+ self.play(ShowCreation(arrow))
self.play(FadeIn(bottom))
self.wait()
@@ -458,7 +458,7 @@ class IntimidatingProf(Scene):
self.add(randy, morty)
self.play(
FadeIn(morty_name1),
- ShowCreation(arrow, submobject_mode = "one_at_a_time")
+ ShowCreation(arrow)
)
self.play(Transform(morty_name1, morty_name2))
self.wait()
@@ -614,10 +614,9 @@ class PhysicsExample(Scene):
vy_label.next_to(vy, RIGHT)
vy_label.set_color(vy.get_color())
- kwargs = {"submobject_mode" : "one_at_a_time"}
for v in v_mob, vx, vy:
self.play(
- ShowCreation(v, submobject_mode = "one_at_a_time")
+ ShowCreation(v)
)
self.play(
ShowCreation(arc),
@@ -687,7 +686,7 @@ class MatricesAre(Scene):
matrix.next_to(arrow, LEFT)
self.play(Write(matrix, run_time = 1))
- self.play(ShowCreation(arrow, submobject_mode = "one_at_a_time"))
+ self.play(ShowCreation(arrow))
self.wait()
class ExampleTransformationForIntuitionList(LinearTransformationScene):
@@ -756,7 +755,7 @@ class DeterminantsAre(Scene):
self.play(
Write(tex_mob),
- ShowCreation(arrow, submobject_mode = "one_at_a_time"),
+ ShowCreation(arrow),
run_time = 1
)
@@ -849,7 +848,7 @@ class TableOfContents(Scene):
self.play(
ApplyMethod(entry3.set_color, YELLOW),
- ShowCreation(arrow, submobject_mode = "one_at_a_time"),
+ ShowCreation(arrow),
Write(added_words),
run_time = 1
)
@@ -954,7 +953,7 @@ class DifferingBackgrounds(Scene):
arrow_anim = Transform(last_arrow, arrow)
else:
word_anim = Write(word, run_time = 1)
- arrow_anim = ShowCreation(arrow, submobject_mode = "one_at_a_time")
+ arrow_anim = ShowCreation(arrow)
last_word = word
last_arrow = arrow
self.play(
diff --git a/old_projects/eola/chapter1.py b/old_projects/eola/chapter1.py
index 0ad6ef631..bfd7680ad 100644
--- a/old_projects/eola/chapter1.py
+++ b/old_projects/eola/chapter1.py
@@ -77,12 +77,11 @@ class DifferentConceptions(Scene):
self.play(ShowCreation(
plane,
- submobject_mode = "lagged_start",
+ lag_ratio=1,
run_time = 3
))
self.play(ShowCreation(
vector,
- submobject_mode = "one_at_a_time"
))
self.play(
Write(labels),
@@ -326,7 +325,7 @@ class DifferentConceptions(Scene):
self.play(
Write(syms), Write(arrays),
- ShowCreation(arrows, submobject_mode = "one_at_a_time"),
+ ShowCreation(arrows),
ApplyMethod(mathy.change_mode, "pondering"),
run_time = 2
)
@@ -459,7 +458,7 @@ class HowIWantYouToThinkAboutVectors(Scene):
tail_word.shift(0.5*DOWN+2.5*LEFT)
line = Line(tail_word, dot)
- self.play(ShowCreation(vector, submobject_mode = "one_at_a_time"))
+ self.play(ShowCreation(vector))
self.wait(2)
self.play(
ShowCreation(plane, summobject_mode = "lagged_start"),
@@ -494,7 +493,6 @@ class HowIWantYouToThinkAboutVectors(Scene):
self.play(ShowCreation(
other_vectors,
- submobject_mode = "one_at_a_time",
run_time = 3
))
self.wait(3)
@@ -564,7 +562,7 @@ class CoordinateSystemWalkthrough(VectorScene):
self.remove(origin_words, dot, line)
self.wait()
self.play(
- ShowCreation(tick_marks, submobject_mode = "one_at_a_time")
+ ShowCreation(tick_marks)
)
self.play(
GrowFromCenter(unit_brace),
@@ -606,7 +604,7 @@ class CoordinateSystemWalkthrough(VectorScene):
point_word.next_to(point, DOWN)
point.add(point_word)
- self.play(ShowCreation(vector, submobject_mode = "one_at_a_time"))
+ self.play(ShowCreation(vector))
self.play(Write(array))
self.wait(2)
self.play(ApplyMethod(x_label_copy.next_to, x_line, DOWN))
@@ -753,13 +751,13 @@ class AddingNumbersOnNumberLine(Scene):
sum_mob = TexMobject("2 + 5").shift(3*UP)
- self.play(ShowCreation(number_line, submobject_mode = "one_at_a_time"))
+ self.play(ShowCreation(number_line))
self.wait()
self.play(Write(sum_mob, run_time = 2))
self.wait()
for vect, num in zip(vects, nums):
self.play(
- ShowCreation(vect, submobject_mode = "one_at_a_time"),
+ ShowCreation(vect),
Write(num, run_time = 1)
)
self.wait()
@@ -1214,8 +1212,7 @@ class ManipulateSpace(LinearTransformationScene):
self.plane.prepare_for_nonlinear_transform()
self.play(ShowCreation(
- self.plane,
- submobject_mode = "one_at_a_time",
+ self.plane,
run_time = 2
))
self.play(FadeIn(pi_creature))
diff --git a/old_projects/eola/chapter11.py b/old_projects/eola/chapter11.py
index 9a51f71df..fa7b8cf7b 100644
--- a/old_projects/eola/chapter11.py
+++ b/old_projects/eola/chapter11.py
@@ -449,7 +449,6 @@ class DeterminantAndEigenvectorDontCare(LinearTransformationScene):
self.play(
ShowCreation(
eigenvectors,
- submobject_mode = "one_at_a_time",
run_time = 2,
),
Animation(words)
@@ -2047,7 +2046,6 @@ class ShowVectorSpaces(Scene):
self.add(h_line, *v_lines)
self.play(ShowCreation(
vectors,
- submobject_mode = "one_at_a_time",
run_time = 3
))
self.play(Write(arrays))
diff --git a/old_projects/eola/chapter2.py b/old_projects/eola/chapter2.py
index 593376491..1173592d0 100644
--- a/old_projects/eola/chapter2.py
+++ b/old_projects/eola/chapter2.py
@@ -645,7 +645,6 @@ class VectorsToDotsScene(VectorScene):
self.play(
ShowCreation(
vector_group,
- submobject_mode = "one_at_a_time",
run_time = 3
)
)
@@ -843,7 +842,7 @@ class LinearCombinationOfThreeVectorsText(Scene):
self.play(Write(equation))
self.wait()
self.play(
- ShowCreation(arrows, submobject_mode = "one_at_a_time"),
+ ShowCreation(arrows),
Write(span_comment)
)
self.wait()
diff --git a/old_projects/mvcr.py b/old_projects/mvcr.py
index f8051f653..329470902 100644
--- a/old_projects/mvcr.py
+++ b/old_projects/mvcr.py
@@ -514,7 +514,7 @@ class ComputationalNetwork(MovingCameraScene):
for x in range(3):
self.play(ShowCreationThenDestruction(
top_lines,
- submobject_mode="one_at_a_time"
+ lag_ratio=1,
))
self.wait()
self.play(
@@ -550,7 +550,7 @@ class ComputationalNetwork(MovingCameraScene):
self.play(*[
ShowCreationThenDestruction(
group,
- submobject_mode="one_at_a_time"
+ lag_ratio=1,
)
for group in (top_lines, bottom_lines)
])
diff --git a/old_projects/patreon.py b/old_projects/patreon.py
index 495b9c1a9..8d5f9d3e1 100644
--- a/old_projects/patreon.py
+++ b/old_projects/patreon.py
@@ -315,14 +315,14 @@ class GrowRonaksSierpinski(Scene):
run_time = 1
for n, sierp_layer, dot_layer in zip(it.count(1), sierp_layers, dot_layers[1:]):
self.play(
- ShowCreation(sierp_layer, submobject_mode = "one_at_a_time"),
+ ShowCreation(sierp_layer, lag_ratio=1),
Animation(last_dot_layer),
run_time = run_time
)
self.play(ShowCreation(
dot_layer,
run_time = run_time,
- submobject_mode = "all_at_once"
+ lag_ratio=1,
))
# if n == 2:
# dot = dot_layer[1]
@@ -618,7 +618,6 @@ class IntegrationByParts(Scene):
self.play(
ShowCreation(
v_lines,
- submobjects = "one_at_a_time",
run_time = 2
),
Animation(curve),
@@ -630,7 +629,6 @@ class IntegrationByParts(Scene):
self.play(
ShowCreation(
h_lines,
- submobjects = "one_at_a_time",
run_time = 2
),
Animation(curve),