Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

zoom in on BrickRowScene

Ben Hambrecht76cb6eee28cd
diff --git a/active_projects/eop/chapter1/entire_brick_wall.py b/active_projects/eop/chapter1/entire_brick_wall.py
index 90c52e293..033cfbae8 100644
--- a/active_projects/eop/chapter1/entire_brick_wall.py
+++ b/active_projects/eop/chapter1/entire_brick_wall.py
@@ -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
+ )
+ )
diff --git a/active_projects/eop/reusables/brick_row.py b/active_projects/eop/reusables/brick_row.py
index 92ca15f79..4e5336166 100644
--- a/active_projects/eop/reusables/brick_row.py
+++ b/active_projects/eop/reusables/brick_row.py
@@ -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))
diff --git a/utils/rate_functions.py b/utils/rate_functions.py
index f9ebb1422..fe43c48ae 100644
--- a/utils/rate_functions.py
+++ b/utils/rate_functions.py
@@ -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)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+