Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

resolved conflicts…

Ben Hambrecht03cb33645f92
diff --cc active_projects/eop/chapter1/entire_brick_wall.py
index 83414d38e,f716d7600..5302bcc72
--- a/active_projects/eop/chapter1/entire_brick_wall.py
+++ b/active_projects/eop/chapter1/entire_brick_wall.py
@@@ -20,11 -22,9 +22,10 @@@ class EntireBrickWall(BrickRowScene)
nb_flips_text = TextMobject("\# of flips")
nb_flips_text.next_to(zero_counter, RIGHT, buff = LARGE_BUFF)
self.add(zero_counter, nb_flips_text)
+ flip_counters = VGroup(zero_counter)
- for i in range(1,nb_rows + 1):
- rows.add(BrickRow(i, height = row_height))
- rows[-1].move_to(start_point + (i - 1) * row_height * DOWN)
+ for i in range(1, nb_rows + 1):
+ rows.add(rows[-1].copy())
self.bring_to_back(rows[-1])
anims = [
rows[-1].shift, row_height * DOWN,
@@@ -64,67 -69,16 +71,74 @@@
FadeIn(nb_tails_text)
)
+ # remove any hidden brick rows
+ hidden_brick_rows = VGroup(*[mob for mob in self.mobjects
+ if isinstance(mob, BrickRow) and not mob in rows
+ ])
+ self.remove(hidden_brick_rows)
+
- special_brick_copy = rows[-1].rects[13].copy()
+ mobs_to_shift = VGroup(
+ rows, flip_counters, tails_counters, nb_tails_text,
+ )
+ self.play(mobs_to_shift.shift, 3 * UP)
+
+ last_row_rect = SurroundingRectangle(rows[-1], buff = 0)
+ last_row_rect.set_stroke(color = YELLOW, width = 6)
++
self.play(
rows.fade, 0.9,
- FadeIn(special_brick_copy)
+ ShowCreation(last_row_rect)
)
+
+ def highlighted_brick(row = 20, nb_tails = 10):
+ brick_copy = rows[row].rects[nb_tails].copy()
+ brick_copy.set_fill(color = YELLOW, opacity = 0.8)
+ prob_percentage = float(choose(row, nb_tails)) / 2**row * 100
+ brick_label = DecimalNumber(prob_percentage, unit = "\%", num_decimal_places = 1, color = BLACK)
+ brick_label.move_to(brick_copy)
+ brick_label.scale_to_fit_height(0.8 * brick_copy.get_height())
+ return VGroup(brick_copy, brick_label)
+
+ highlighted_bricks = [
+ highlighted_brick(row = 20, nb_tails = i)
+ for i in range(20)
+ ]
+
+ self.play(
+ FadeIn(highlighted_bricks[10])
+ )
+
+ self.play(
+ FadeOut(highlighted_bricks[10]),
+ FadeIn(highlighted_bricks[9]),
+ FadeIn(highlighted_bricks[11]),
+ )
+
+ self.play(
+ FadeOut(highlighted_bricks[9]),
+ FadeOut(highlighted_bricks[11]),
+ FadeIn(highlighted_bricks[8]),
+ FadeIn(highlighted_bricks[12]),
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+