3b1b-videos/_2018/eop/chapter1/just_randy_flipping_coin.py
2021-01-01 20:10:38 -08:00

39 lines
943 B
Python

from manim_imports_ext import *
from _2018.eop.reusable_imports import *
class JustFlipping(Scene):
def construct(self):
randy = CoinFlippingPiCreature(color = MAROON_E, flip_height = 1).shift(2 * DOWN)
self.add(randy)
self.wait(2)
for i in range(10):
self.wait()
self.play(FlipCoin(randy))
class JustFlippingWithResults(Scene):
def construct(self):
randy = CoinFlippingPiCreature(color = MAROON_E, flip_height = 1).shift(2 * DOWN)
self.add(randy)
self.wait(2)
for i in range(10):
self.wait()
self.play(FlipCoin(randy))
result = random.choice(["H", "T"])
if result == "H":
coin = UprightHeads().scale(3)
else:
coin = UprightTails().scale(3)
coin.move_to(2 * UP + 2.5 * LEFT + i * 0.6 * RIGHT)
self.play(FadeIn(coin))