aboutsummaryrefslogtreecommitdiffstats
path: root/scenes/v14_gabriel.py
blob: 2a36935f3af685e14a39986ca33aefa42e4fa3d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# -*- coding: utf-8 -*-
import sys, os, math
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from manim import *
from tiktok import *

XA, XB = 1.0, 7.4       # domain of 1/x
KX, KY = 1.00, 2.00     # scale to screen
X0S, CY = -3.75, 1.70


def sx(x):
    return X0S + (x - XA) * KX


def sy(x):
    return KY / x


def branch(next_one, n=160, **kw):
    xs = np.linspace(XA, XB, n)
    pts = [[sx(x), CY + next_one * sy(x), 0] for x in xs]
    m = VMobject(**kw)
    m.set_points_as_corners(pts)
    return m


def body_obj(fill="#1E4E8C", op=0.55):
    xs = np.linspace(XA, XB, 160)
    up = [[sx(x), CY + sy(x), 0] for x in xs]
    dn = [[sx(x), CY - sy(x), 0] for x in reversed(xs)]
    m = VMobject(stroke_width=0, fill_color=fill, fill_opacity=op)
    m.set_points_as_corners(up + dn + [up[0]])
    return m


def hoops(n=9, col=C_SKY, op=0.55):
    xs = np.linspace(XA + 0.35, XB, n)
    return VGroup(*[
        Ellipse(width=0.34, height=2 * sy(x), stroke_width=3, stroke_opacity=op,
                color=col).move_to([sx(x), CY, 0]) for x in xs])


class Gabriel(TikTok):
    NAME = "gabriel"

    def construct(self):
        self.prepare()
        chip = self.chip("Paradoja del infinito", C_SKY)

        with self.beat(0) as b:
            b.play(FadeIn(chip, shift=DOWN * 0.3), run_time=0.45)
            t = VGroup(
                self.fit(Text("el cuerno de", font=FONT, font_size=50,
                              weight=BOLD, color=WHITE), 8.0),
                self.fit(Text("GABRIEL", font=FONT, font_size=86,
                              weight=BOLD, color=AMBER), 8.0),
            ).arrange(DOWN, buff=0.25).move_to(UP * 2.6)
            b.play(FadeIn(t[0], shift=UP * 0.15), run_time=0.5)
            b.play(FadeIn(t[1], scale=0.7), run_time=0.8)

        axis_obj = Line([sx(XA) - 0.5, CY, 0], [sx(XB) + 0.35, CY, 0],
                   stroke_width=3, color="#33405C")

        with self.beat(1) as b:
            b.play(t.animate.scale(0.5).move_to(UP * 5.3), run_time=0.5)
            f = MathTex(r"y = \frac{1}{x}", color=AMBER).scale(1.35).move_to(DOWN * 2.4)
            up = branch(+1, stroke_color=AMBER, stroke_width=6)
            b.play(FadeIn(axis_obj), run_time=0.3)
            b.play(Create(up), run_time=0.9)
            b.play(Write(f), run_time=0.7)

        body = body_obj()
        low = branch(-1, stroke_color=AMBER, stroke_width=6)
        ar = hoops()
        mouth = Ellipse(width=0.42, height=2 * sy(XA), stroke_width=6,
                       color=AMBER).move_to([sx(XA), CY, 0])

        with self.beat(2) as b:
            b.play(Create(low), run_time=0.6)
            b.play(FadeIn(body), FadeIn(mouth), run_time=0.5)
            b.play(LaggedStart(*[Create(a) for a in ar], lag_ratio=0.15), run_time=0.9)
            inf = MathTex(r"\cdots \infty", color=C_GRAY).scale(1.0)
            inf.next_to([sx(XB), CY, 0], RIGHT, buff=0.2)
            b.play(FadeIn(inf), run_time=0.4)

        horn = VGroup(axis_obj, body, up, low, ar, mouth, inf)

        with self.beat(3) as b:
            b.play(FadeOut(f), run_time=0.25)
            q = self.fit(Text("¿cuánta pintura entra?", font=FONT, font_size=52,
                              weight=BOLD, color=WHITE), 8.2).move_to(DOWN * 2.3)
            b.play(FadeIn(q, shift=UP * 0.15), run_time=0.7)

        with self.beat(4) as b:
            b.play(FadeOut(q), run_time=0.25)
            filled = body_obj(fill=C_GREEN, op=0.85)
            b.play(FadeIn(filled), run_time=0.7)
            v = MathTex(r"V = \pi\int_1^{\infty}\frac{dx}{x^2} = \pi",
                        color=C_GREEN).scale(1.15).move_to(DOWN * 2.05)
            b.play(Write(v), run_time=1.1)

        with self.beat(5) as b:
            lt = self.fit(Text("≈ 3,14 litros y te sobra", font=FONT, font_size=48,
                               weight=BOLD, color=C_GREEN), 8.2).move_to(DOWN * 2.90)
            b.play(FadeIn(lt, shift=UP * 0.15), run_time=0.7)

        with self.beat(6) as b:
            b.play(FadeOut(VGroup(v, lt, filled)), run_time=0.4)
            q2 = self.fit(Text("¿y pintarlo por fuera?", font=FONT, font_size=52,
                               weight=BOLD, color=WHITE), 8.2).move_to(DOWN * 2.3)
            b.play(up.animate.set_stroke(C_PINK, 8), low.animate.set_stroke(C_PINK, 8),
                   run_time=0.6)
            b.play(FadeIn(q2, shift=UP * 0.15), run_time=0.6)

        with self.beat(7) as b:
            b.play(FadeOut(q2), run_time=0.25)
            a = MathTex(r"A > 2\pi\int_1^{\infty}\frac{dx}{x} = \infty",
                        color=C_PINK).scale(1.15).move_to(DOWN * 2.15)
            b.play(Write(a), run_time=1.1)
            b.play(Flash(a, color=C_PINK, line_length=0.5, num_lines=18,
                         flash_radius=2.4), run_time=0.7)

        with self.beat(8) as b:
            b.play(FadeOut(VGroup(a, horn)), run_time=0.45)
            def row(txt, val, col):
                t1 = Text(txt, font=FONT, font_size=44, weight=BOLD, color=WHITE)
                t2 = Text(val, font=FONT, font_size=56, weight=BOLD, color=col)
                return VGroup(t1, t2).arrange(DOWN, buff=0.18)
            cmp = VGroup(row("volumen", "π  (finito)", C_GREEN),
                         row("superficie", "∞  (infinita)", C_PINK)
                         ).arrange(DOWN, buff=0.75).move_to(UP * 2.4)
            self.fit(cmp, 8.2)
            b.play(FadeIn(cmp[0], shift=UP * 0.15), run_time=0.55)
            b.play(FadeIn(cmp[1], shift=UP * 0.15), run_time=0.55)
            impact = VGroup(
                self.fit(Text("lo llenás de pintura", font=FONT, font_size=48,
                              weight=BOLD, color=WHITE), 8.2),
                self.fit(Text("pero no lo podés pintar", font=FONT, font_size=48,
                              weight=BOLD, color=AMBER), 8.2),
            ).arrange(DOWN, buff=0.3).move_to(DOWN * 0.6)
            b.play(FadeIn(impact, scale=0.85), run_time=0.8)

        with self.beat(9) as b:
            b.play(FadeOut(VGroup(cmp, impact)), run_time=0.4)
            tr = VGroup(
                self.fit(Text("la trampa:", font=FONT, font_size=48,
                              weight=BOLD, color=C_PINK), 8.2),
                self.fit(Text("la pintura real tiene", font=FONT, font_size=46,
                              weight=BOLD, color=WHITE), 8.2),
                self.fit(Text("espesor. El cuerno", font=FONT, font_size=46,
                              weight=BOLD, color=WHITE), 8.2),
                self.fit(Text("se hace más fino que eso.", font=FONT, font_size=46,
                              weight=BOLD, color=WHITE), 8.2),
            ).arrange(DOWN, buff=0.3).move_to(UP * 1.8)
            for k in range(4):
                b.play(FadeIn(tr[k], shift=UP * 0.12), run_time=0.45)

        with self.beat(10) as b:
            b.play(FadeOut(tr), run_time=0.35)
            count_txt = VGroup(
                self.fit(Text("con el infinito", font=FONT, font_size=52,
                              weight=BOLD, color=WHITE), 8.0),
                self.fit(Text("la intuición se rompe", font=FONT, font_size=56,
                              weight=BOLD, color=AMBER), 8.0),
            ).arrange(DOWN, buff=0.35).move_to(UP * 1.4)
            b.play(FadeIn(count_txt[0], shift=UP * 0.15), run_time=0.55)
            b.play(Write(count_txt[1]), run_time=0.9)
            b.play(Circumscribe(count_txt[1], color=AMBER, buff=0.25, stroke_width=6),
                   run_time=0.8)

        self.finish()