Get rid of lag_factor

This commit is contained in:
Grant Sanderson 2019-02-08 18:42:40 -08:00
parent f1b847deff
commit 707a2f6f63
22 changed files with 39 additions and 54 deletions

View file

@ -43,7 +43,7 @@ class IllustrateAreaModelBayes(Scene):
label_not_A = TexMobject("P(\\text{not }A)").next_to(brace_not_A, DOWN).scale(0.7)
# self.play(
# OldLaggedStart(FadeIn, VGroup(rect_A, rect_not_A), lag_factor = 0.5)
# OldLaggedStart(FadeIn, VGroup(rect_A, rect_not_A))
# )
# self.play(
# ShowCreation(brace_A),
@ -75,7 +75,7 @@ class IllustrateAreaModelBayes(Scene):
label_not_B = TexMobject("P(\\text{not }B)").next_to(brace_not_B, LEFT).scale(0.7)
# self.play(
# OldLaggedStart(FadeIn, VGroup(rect_B, rect_not_B), lag_factor = 0.5)
# OldLaggedStart(FadeIn, VGroup(rect_B, rect_not_B))
# )
# self.play(
# ShowCreation(brace_B),

View file

@ -6,7 +6,6 @@ class Chapter1OpeningQuote(OpeningQuote):
"fade_in_kwargs": {
"lag_ratio": 0.5,
"rate_func": linear,
"lag_factor": 9,
"run_time": 10,
},
"text_size" : "\\normalsize",

View file

@ -1023,7 +1023,6 @@ class ThousandPossibleQuizzes(Scene):
MoveToTarget(
movers,
lag_ratio = 0.5,
lag_factor = 4,
run_time = 3,
),
Transform(left_label_equation, new_equation)

View file

@ -15,16 +15,12 @@ class Animation(object):
"name": None,
# Does this animation add or remove a mobject form the screen
"remover": False,
# TODO, replace this with a single lag parameter
# If 0, the animation is applied to all submobjects
# at the same time
# If 1, it is applied to each successively.
# If 0 < lag_ratio < 1, its applied to each
# with lagged start times
"lag_ratio": 0,
# TODO, remove anything with lag_factor
"lag_factor": 2,
}
def __init__(self, mobject, **kwargs):

View file

@ -116,12 +116,7 @@ class Write(DrawBorderThenFill):
if "run_time" not in kwargs:
self.establish_run_time(mobject)
if "lag_factor" not in kwargs:
if len(mobject.family_members_with_points()) < 4:
min_lag_factor = 1
else:
min_lag_factor = 2
self.lag_factor = max(self.run_time - 1, min_lag_factor)
# Something to be smart about lag_ratio?
DrawBorderThenFill.__init__(self, mobject, **kwargs)
def establish_run_time(self, mobject):

View file

@ -211,7 +211,6 @@ class ApplyWave(Homotopy):
def homotopy(x, y, z, t):
alpha = (x - left_x) / (right_x - left_x)
# lf = self.lag_factor
power = np.exp(2.0 * (alpha - 0.5))
nudge = there_and_back(t**power)
return np.array([x, y, z]) + nudge * vect

View file

@ -119,15 +119,18 @@ class CounterclockwiseTransform(Transform):
class MoveToTarget(Transform):
def __init__(self, mobject, **kwargs):
self.check_validity_of_input(mobject)
Transform.__init__(self, mobject, mobject.target, **kwargs)
def check_validity_of_input(self, mobject):
if not hasattr(mobject, "target"):
raise Exception(
"MoveToTarget called on mobject without attribute 'target' ")
Transform.__init__(self, mobject, mobject.target, **kwargs)
"MoveToTarget called on mobject"
"without attribute 'target'"
)
class ApplyMethod(Transform):
CONFIG = {}
def __init__(self, method, *args, **kwargs):
"""
method is a method of Mobject, *args are arguments for
@ -183,10 +186,17 @@ class ApplyPointwiseFunction(ApplyMethod):
class ApplyPointwiseFunctionToCenter(ApplyPointwiseFunction):
def __init__(self, function, mobject, **kwargs):
self.function = function
ApplyMethod.__init__(
self, mobject.move_to, function(mobject.get_center()), **kwargs
self, mobject.move_to, **kwargs
)
def begin(self):
self.method_args = [
self.function(self.mobject.get_center())
]
super().begin()
class FadeToColor(ApplyMethod):
def __init__(self, mobject, color, **kwargs):
@ -195,8 +205,9 @@ class FadeToColor(ApplyMethod):
class ScaleInPlace(ApplyMethod):
def __init__(self, mobject, scale_factor, **kwargs):
ApplyMethod.__init__(self, mobject.scale_in_place,
scale_factor, **kwargs)
ApplyMethod.__init__(
self, mobject.scale, scale_factor, **kwargs
)
class Restore(ApplyMethod):
@ -205,18 +216,18 @@ class Restore(ApplyMethod):
class ApplyFunction(Transform):
CONFIG = {
"lag_ratio": 0,
}
def __init__(self, function, mobject, **kwargs):
self.function = function
temp_target = mobject
Transform.__init__(
self,
mobject,
function(mobject.copy()),
**kwargs
self, mobject, temp_target, **kwargs
)
self.name = "ApplyFunctionTo" + str(mobject)
def begin(self):
self.target_mobject = self.function(
self.mobject.copy()
)
super().begin()
class ApplyMatrix(ApplyPointwiseFunction):

View file

@ -35,7 +35,6 @@ class OpeningQuote(Scene):
"fade_in_kwargs": {
"lag_ratio": 0.5,
"rate_func": linear,
"lag_factor": 4,
"run_time": 5,
},
"text_size": "\\Large",
@ -272,7 +271,7 @@ class LogoGenerationTemplate(MovingCameraScene):
name = self.channel_name
self.play(
Write(name, run_time=3, lag_factor=2.5),
Write(name, run_time=3),
*self.get_logo_animations(logo)
)
self.wait()

View file

@ -2980,7 +2980,6 @@ class IntroduceBlockChain(Scene):
OldLaggedStart(
ShowCreation, arrows,
run_time = 1,
lag_factor = 0.6,
)
)
self.wait()

View file

@ -978,7 +978,7 @@ class UseDefiningFeatures(Scene):
tip.set_color(YELLOW)
self.add(title)
self.play(Write(tip, lag_factor=5, run_time=4))
self.play(Write(tip, run_time=4))
self.wait()
@ -1272,7 +1272,7 @@ class NameDandelin(Scene):
self.add(title[0])
self.play(FadeInFromDown(portrait))
self.play(Write(title[1], lag_factor=4))
self.play(Write(title[1]))
self.wait()
self.play(FadeInFrom(google_result, LEFT))
self.play(Write(cmon_google, run_time=1))

View file

@ -1728,7 +1728,6 @@ class ThreeLinesChainRule(ReconfigurableScene):
self.play(
all_x_squared_relevant_labels.restore,
lag_ratio = 0.5,
lag_factor = 3,
run_time = 3,
)
self.__dict__.update(self.__class__.CONFIG)

View file

@ -104,7 +104,6 @@ class LimitJustMeansApproach(PiCreatureScene):
Transform(
expression, next_expression,
lag_ratio = 0.5,
lag_factor = 1.2,
),
self.pi_creature.look_at, next_expression[-1]
)
@ -664,7 +663,6 @@ class OtherViewsOfDx(TeacherStudentsScene):
statements[0].h.copy(), h_group,
run_time = 2,
lag_ratio = 0.5,
lag_factor = 1.5,
))
self.wait()
@ -824,7 +822,6 @@ class GraphLimitExpression(GraphScene):
anims = [FadeIn(
VGroup(*expression[i:j]),
lag_ratio = 0.5,
lag_factor = 1.5
)]
new_graph = self.get_graph(func, color = BLUE)
if graph is None:

View file

@ -2413,7 +2413,7 @@ class FundamentalTheorem(GraphScene):
""")
words.to_edge(RIGHT)
self.play(Write(words, lag_factor = 3))
self.play(Write(words))
self.wait()
def show_integral_considering_continuum(self):

View file

@ -47,7 +47,6 @@ class OpeningQuote(Scene):
self.play(Write(
quote,
run_time = rt,
lag_factor = 5 if rt > 3 else 2,
))
self.wait(2)
@ -2121,7 +2120,7 @@ class RememberGraphDuality(Scene):
early video I did on graph duality
""")
words.to_edge(UP)
self.play(Write(words, lag_factor = 4))
self.play(Write(words))
self.wait()
class LooseDualityDescription(Scene):

View file

@ -899,7 +899,7 @@ class IntroduceBase10(Scene):
""")
digits.next_to(self.title, DOWN, buff = LARGE_BUFF)
digits.shift(2*RIGHT)
self.play(Write(digits, lag_factor = 5))
self.play(Write(digits))
self.wait()
class RhythmOfDecimalCounting(CountingScene):
@ -1181,7 +1181,6 @@ class BinaryCountingAtEveryScale(Scene):
VGroup(*reversed(list(curr_bits))),
VGroup(*reversed(list(bit_mobs[2**(self.num_bits-1)]))),
lag_ratio = 0.5,
lag_factor = self.num_bits
))
self.wait()
self.play(
@ -2970,7 +2969,6 @@ class IntroduceGraphStructure(SierpinskiGraphScene):
self.nodes,
run_time = 3,
lag_ratio = 0.5,
lag_factor = 7,
))
vect = LEFT
for index in 3, 21, 8, 17, 10, 13:

View file

@ -819,7 +819,6 @@ class CountLatticePoints(LatticePointScene):
point_copies, squares,
run_time = 3,
lag_ratio = 0.5,
lag_factor = 4,
),
Animation(self.lattice_points)
)

View file

@ -670,7 +670,6 @@ class LayOutPlan(TeacherStudentsScene, NetworkScene):
network_mob.edge_groups,
lag_ratio = 0.5,
run_time = 2,
lag_factor = 8,
rate_func=linear,
))
in_vect = np.random.random(self.network.sizes[0])

View file

@ -2673,7 +2673,6 @@ class GradientNudging(PreviewLearning):
return MoveToTarget(
edges,
lag_ratio = 0.5,
lag_factor = 8,
run_time = 1.5
)

View file

@ -163,7 +163,6 @@ class GrowingToDoList(Scene):
morty.look_at, lines,
Write(
VGroup(*lines[3:]),
lag_factor = 7
)
)
@ -551,7 +550,6 @@ class MakeALotOfPiCreaturesHappy(Scene):
pis,
run_time = 2,
lag_ratio = 0.5,
lag_factor = 5,
)
)
for x in range(10):

View file

@ -971,7 +971,7 @@ class FeynmanOnTurbulence(Scene):
self.play(
FadeInFrom(feynman, UP),
FadeInFrom(name, DOWN),
Write(quote, run_time=4, lag_factor=5)
Write(quote, run_time=4)
)
self.wait()

View file

@ -4066,7 +4066,7 @@ class MentionJohnWallis(Scene):
self.play(GrowFromEdge(image, UP))
self.play(Write(image_name))
self.wait(2)
self.play(Write(infinity, run_time=3, lag_factor=1))
self.play(Write(infinity, run_time=3))
self.wait(2)

View file

@ -2060,7 +2060,7 @@ class CreditThree(Scene):
)
self.wait()
self.play(
Write(domains, run_time = 5, lag_factor = 5),
Write(domains, run_time = 5),
randy.look_at, domains
)
self.wait()