diff --git a/active_projects/eop/chapter1/entire_brick_wall.py b/active_projects/eop/chapter1/entire_brick_wall.py index 31d07ec1..83414d38 100644 --- a/active_projects/eop/chapter1/entire_brick_wall.py +++ b/active_projects/eop/chapter1/entire_brick_wall.py @@ -20,6 +20,7 @@ class EntireBrickWall(Scene): 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)) @@ -33,6 +34,7 @@ class EntireBrickWall(Scene): if i % 5 == 0: counter = Integer(i) counter.next_to(rows[-1].get_right() + row_height * DOWN, RIGHT) + flip_counters.add(counter) anims.append(FadeIn(counter)) self.play(*anims) @@ -62,10 +64,67 @@ class EntireBrickWall(Scene): FadeIn(nb_tails_text) ) - 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]), ) + + + + + + + + + + + + + + + + + + + +