zoom in on BrickRowScene

This commit is contained in:
Ben Hambrecht
2018-05-10 00:00:15 +02:00
parent deaf0b1274
commit 76cb6eee28
3 changed files with 50 additions and 6 deletions

View File

@ -3,7 +3,12 @@ from big_ol_pile_of_manim_imports import *
from active_projects.eop.reusable_imports import *
from active_projects.eop.chapter1.brick_row_scene import BrickRowScene
class EntireBrickWall(BrickRowScene):
class EntireBrickWall(BrickRowScene, MovingCameraScene):
def setup(self):
super(BrickRowScene, self).setup()
super(PiCreatureScene, self).setup()
def construct(self):
@ -45,7 +50,6 @@ class EntireBrickWall(BrickRowScene):
rows.submobjects[-1] = self.merge_rects_by_coloring(rows[-1])
# draw indices under the last row for the number of tails
tails_counters = VGroup()
for (i, rect) in enumerate(rows[-1].rects):
@ -83,6 +87,7 @@ class EntireBrickWall(BrickRowScene):
last_row_rect = SurroundingRectangle(rows[-1], buff = 0)
last_row_rect.set_stroke(color = YELLOW, width = 6)
rows.save_state()
self.play(
rows.fade, 0.9,
ShowCreation(last_row_rect)
@ -102,24 +107,40 @@ class EntireBrickWall(BrickRowScene):
highlighted_brick(row = 20, nb_tails = i)
for i in range(20)
]
self.wait()
self.play(
FadeIn(highlighted_bricks[10])
)
self.wait()
self.play(
FadeOut(highlighted_bricks[10]),
FadeIn(highlighted_bricks[9]),
FadeIn(highlighted_bricks[11]),
)
self.wait()
self.play(
FadeOut(highlighted_bricks[9]),
FadeOut(highlighted_bricks[11]),
FadeIn(highlighted_bricks[8]),
FadeIn(highlighted_bricks[12]),
)
self.wait()
self.play(
FadeOut(highlighted_bricks[8]),
FadeOut(highlighted_bricks[12]),
FadeOut(last_row_rect),
rows.restore,
)
self.wait()
new_frame = self.camera_frame.copy()
new_frame.scale(0.0001).move_to(rows.get_corner(DR))
self.play(
Transform(self.camera_frame, new_frame,
run_time = 9,
rate_func = exponential_decay
)
)

View File

@ -184,6 +184,7 @@ class SplitRectsInBrickWall(AnimationGroup):
def __init__(self, mobject, **kwargs):
#print mobject.height, mobject.get_height()
r = self.subdiv_level = mobject.subdiv_level + 1
subdivs = VGroup()
@ -196,6 +197,7 @@ class SplitRectsInBrickWall(AnimationGroup):
subdiv = DashedLine(
mobject.get_top() + x * RIGHT,
mobject.get_bottom() + x * RIGHT,
dashed_segment_length = 0.05
)
subdivs.add(subdiv)
anims.append(ShowCreation(subdiv))

View File

@ -82,3 +82,24 @@ def squish_rate_func(func, a=0.4, b=0.6):
def lingering(t):
return squish_rate_func(lambda t: t, 0, 0.8)(t)
def exponential_decay(t, half_life = 0.1):
# The half-life should be rather small to minimize the cut-off error at the end
return 1 - np.exp(-t/half_life)