mirror of
https://github.com/3b1b/manim.git
synced 2025-08-21 05:44:04 +00:00
resolved conflicts…
# Conflicts: # active_projects/eop/chapter1/entire_brick_wall.py
This commit is contained in:
commit
03cb33645f
1 changed files with 21 additions and 7 deletions
|
@ -1,19 +1,21 @@
|
||||||
|
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from active_projects.eop.reusable_imports import *
|
from active_projects.eop.reusable_imports import *
|
||||||
|
from active_projects.eop.chapter1.brick_row_scene import BrickRowScene
|
||||||
|
|
||||||
|
class EntireBrickWall(BrickRowScene):
|
||||||
class EntireBrickWall(Scene):
|
|
||||||
|
|
||||||
def construct(self):
|
def construct(self):
|
||||||
|
|
||||||
|
self.remove(self.get_primary_pi_creature())
|
||||||
|
|
||||||
row_height = 0.3
|
row_height = 0.3
|
||||||
nb_rows = 20
|
nb_rows = 20
|
||||||
start_point = 3 * UP + 1 * LEFT
|
start_point = 3 * UP + 1 * LEFT
|
||||||
|
|
||||||
rows = VMobject()
|
rows = VMobject()
|
||||||
rows.add(BrickRow(0, height = row_height))
|
rows.add(BrickRow(0, height = row_height))
|
||||||
rows[0].move_to(start_point)
|
rows.move_to(start_point)
|
||||||
self.add(rows)
|
self.add(rows)
|
||||||
|
|
||||||
zero_counter = Integer(0).next_to(start_point + 0.5 * rows[0].width * RIGHT)
|
zero_counter = Integer(0).next_to(start_point + 0.5 * rows[0].width * RIGHT)
|
||||||
|
@ -22,9 +24,8 @@ class EntireBrickWall(Scene):
|
||||||
self.add(zero_counter, nb_flips_text)
|
self.add(zero_counter, nb_flips_text)
|
||||||
flip_counters = VGroup(zero_counter)
|
flip_counters = VGroup(zero_counter)
|
||||||
|
|
||||||
for i in range(1,nb_rows + 1):
|
for i in range(1, nb_rows + 1):
|
||||||
rows.add(BrickRow(i, height = row_height))
|
rows.add(rows[-1].copy())
|
||||||
rows[-1].move_to(start_point + (i - 1) * row_height * DOWN)
|
|
||||||
self.bring_to_back(rows[-1])
|
self.bring_to_back(rows[-1])
|
||||||
anims = [
|
anims = [
|
||||||
rows[-1].shift, row_height * DOWN,
|
rows[-1].shift, row_height * DOWN,
|
||||||
|
@ -39,6 +40,12 @@ class EntireBrickWall(Scene):
|
||||||
|
|
||||||
self.play(*anims)
|
self.play(*anims)
|
||||||
|
|
||||||
|
self.play(SplitRectsInBrickWall(rows[-1]))
|
||||||
|
rows.submobjects[-1] = self.merge_rects_by_subdiv(rows[-1])
|
||||||
|
rows.submobjects[-1] = self.merge_rects_by_coloring(rows[-1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# draw indices under the last row for the number of tails
|
# draw indices under the last row for the number of tails
|
||||||
tails_counters = VGroup()
|
tails_counters = VGroup()
|
||||||
for (i, rect) in enumerate(rows[-1].rects):
|
for (i, rect) in enumerate(rows[-1].rects):
|
||||||
|
@ -64,6 +71,12 @@ class EntireBrickWall(Scene):
|
||||||
FadeIn(nb_tails_text)
|
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)
|
||||||
|
|
||||||
mobs_to_shift = VGroup(
|
mobs_to_shift = VGroup(
|
||||||
rows, flip_counters, tails_counters, nb_tails_text,
|
rows, flip_counters, tails_counters, nb_tails_text,
|
||||||
)
|
)
|
||||||
|
@ -71,6 +84,7 @@ class EntireBrickWall(Scene):
|
||||||
|
|
||||||
last_row_rect = SurroundingRectangle(rows[-1], buff = 0)
|
last_row_rect = SurroundingRectangle(rows[-1], buff = 0)
|
||||||
last_row_rect.set_stroke(color = YELLOW, width = 6)
|
last_row_rect.set_stroke(color = YELLOW, width = 6)
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
rows.fade, 0.9,
|
rows.fade, 0.9,
|
||||||
ShowCreation(last_row_rect)
|
ShowCreation(last_row_rect)
|
||||||
|
|
Loading…
Add table
Reference in a new issue