diff options
| author | Elvis Claros Castro <elvis@claros.ar> | 2026-09-26 20:21:47 -0300 |
|---|---|---|
| committer | Elvis Claros Castro <elvis@claros.ar> | 2026-09-26 20:21:47 -0300 |
| commit | 59355909f2de9236af8168a26c70bcf6caa3b285 (patch) | |
| tree | 686186e2086f81aa22ad25e78eb29fca3cbadc9a /scenes/v4_luna.py | |
| download | 100cia-videos-59355909f2de9236af8168a26c70bcf6caa3b285.tar.gz 100cia-videos-59355909f2de9236af8168a26c70bcf6caa3b285.zip | |
Import video pipeline as it was
Diffstat (limited to 'scenes/v4_luna.py')
| -rw-r--r-- | scenes/v4_luna.py | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/scenes/v4_luna.py b/scenes/v4_luna.py new file mode 100644 index 0000000..f69f99a --- /dev/null +++ b/scenes/v4_luna.py @@ -0,0 +1,178 @@ +# -*- coding: utf-8 -*- +import sys, os, math +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from manim import * +from tiktok import * + +Y0, Y1 = -3.25, 4.20 # extremos del eje logaritmico +L0, L1 = -1.0, 11.8 # log10 del espesor en mm +BAR_X, BAR_W = -3.15, 1.0 +MOON_MM = 3.844e11 + + +def ypos(mm): + L = max(min(math.log10(mm), L1), L0) + return Y0 + (L - L0) / (L1 - L0) * (Y1 - Y0) + + +def espesor(n): + return 0.1 * (2 ** n) + + +def humano(mm): + if mm < 10: + return f"{mm:.1f} mm".replace(".", ",") + if mm < 1e4: + return f"{mm/10:.0f} cm" + if mm < 1e7: + return f"{mm/1000:,.0f} m".replace(",", ".") + return f"{mm/1e6:,.0f} km".replace(",", ".") + + +class Luna(TikTok): + NAME = "luna" + + def moon(self, r=0.62): + m = Circle(radius=r, stroke_width=0, fill_color="#D9DEE8", fill_opacity=1) + cr = VGroup( + Dot(m.get_center() + LEFT * 0.2 * r + UP * 0.3 * r, radius=0.16 * r, color="#AEB6C6"), + Dot(m.get_center() + RIGHT * 0.35 * r + DOWN * 0.1 * r, radius=0.11 * r, color="#AEB6C6"), + Dot(m.get_center() + LEFT * 0.1 * r + DOWN * 0.42 * r, radius=0.09 * r, color="#AEB6C6"), + ) + return VGroup(m, cr) + + def construct(self): + self.prepare() + chip = self.chip("Crecimiento exponencial", CELESTE) + + # ---------- hook ---------- + with self.beat(0) as b: + sheet = Rectangle(width=1.9, height=2.5, stroke_color="#C9D2E3", stroke_width=5, + fill_color="#1A2440", fill_opacity=1).move_to(LEFT * 2.3 + UP * 2.6) + fold = Line(sheet.get_corner(UL) + RIGHT * 0.55, sheet.get_corner(DL) + RIGHT * 0.55, + stroke_width=3, color="#5E6B87") + mo = self.moon(0.95).move_to(RIGHT * 2.4 + UP * 2.6) + ar = Arrow(sheet.get_right() + RIGHT * 0.15, mo.get_left() + LEFT * 0.15, + buff=0, color=AMBAR, stroke_width=9) + tag = self.fit(Text("42 dobleces", font=FONT, font_size=46, weight=BOLD, + color=AMBAR), 7.5).next_to(ar, UP, buff=0.3) + b.play(FadeIn(chip, shift=DOWN * 0.3), run_time=0.45) + b.play(FadeIn(sheet), Create(fold), run_time=0.5) + b.play(GrowArrow(ar), FadeIn(tag), run_time=0.6) + b.play(FadeIn(mo, scale=0.6), run_time=0.6) + hook = VGroup(sheet, fold, mo, ar, tag) + + # ---------- el eje ---------- + axis = Line([BAR_X, Y0, 0], [BAR_X, Y1 + 0.3, 0], stroke_width=5, color="#3A4766") + base = Line([BAR_X - 0.75, Y0, 0], [4.2, Y0, 0], stroke_width=5, color="#3A4766") + + hitos = [(1e2, "10 cm"), (1e5, "100 m"), (1e8, "100 km")] + marks = VGroup() + for mm, txt in hitos: + y = ypos(mm) + ln = DashedLine([BAR_X - 0.5, y, 0], [3.9, y, 0], stroke_width=3, + color="#33405C", dash_length=0.12) + lb = Text(txt, font=FONT, font_size=30, color=GRIS) + lb.next_to(ln, UP, buff=0.08).align_to(ln, RIGHT) + marks.add(VGroup(ln, lb)) + + ym = ypos(MOON_MM) + moon_line = DashedLine([BAR_X - 0.5, ym, 0], [3.4, ym, 0], stroke_width=4, + color="#D9DEE8", dash_length=0.14) + moon_ic = self.moon(0.42).move_to([3.85, ym, 0]) + moon_lb = Text("LUNA 384.000 km", font=FONT, font_size=30, weight=BOLD, color="#D9DEE8") + moon_lb.next_to(moon_line, UP, buff=0.1).align_to(moon_line, RIGHT).shift(LEFT * 0.1) + + readout = VGroup( + Text("0", font=FONT, font_size=68, weight=BOLD, color=AMBAR), + Text("dobleces", font=FONT, font_size=28, color=GRIS), + Text("0,1 mm", font=FONT, font_size=44, weight=BOLD, color=WHITE), + ) + readout[0:2].arrange(RIGHT, buff=0.25, aligned_edge=DOWN) + readout.arrange(RIGHT, buff=0.5, aligned_edge=DOWN).move_to(UP * 5.6) + + bar = Rectangle(width=BAR_W, height=0.02, stroke_width=0, + fill_color=AMBAR, fill_opacity=1) + bar.move_to([BAR_X + BAR_W / 2 + 0.06, Y0, 0], DOWN + LEFT) + + with self.beat(1) as b: + b.play(FadeOut(hook), run_time=0.4) + b.play(Create(axis), Create(base), run_time=0.5) + b.play(LaggedStart(*[FadeIn(m) for m in marks], lag_ratio=0.2), run_time=0.8) + b.play(Create(moon_line), FadeIn(moon_ic), FadeIn(moon_lb), run_time=0.6) + + state = {"n": 0} + + def goto(bt, n, rt=0.9, extra=None): + mm = espesor(n) + h = max(ypos(mm) - Y0, 0.02) + new_bar = bar.copy().stretch_to_fit_height(h).move_to( + [BAR_X + BAR_W / 2 + 0.06, Y0, 0], DOWN + LEFT) + nr = VGroup( + Text(str(n), font=FONT, font_size=68, weight=BOLD, color=AMBAR), + Text("dobleces" if n != 1 else "doblez", font=FONT, font_size=28, color=GRIS), + Text(humano(mm), font=FONT, font_size=44, weight=BOLD, color=WHITE), + ) + nr[0:2].arrange(RIGHT, buff=0.25, aligned_edge=DOWN) + nr.arrange(RIGHT, buff=0.5, aligned_edge=DOWN).move_to(UP * 5.6) + self.fit(nr, 8.2) + anims = [Transform(bar, new_bar), Transform(readout, nr)] + if extra: + anims += extra + bt.play(*anims, run_time=rt) + state["n"] = n + + with self.beat(2) as b: + b.play(FadeIn(readout), FadeIn(bar), run_time=0.5) + b.play(Indicate(readout[2], color=AMBAR, scale_factor=1.3), run_time=0.7) + + with self.beat(3) as b: + goto(b, 1, 0.7) + goto(b, 2, 0.7) + + with self.beat(4) as b: + goto(b, 10, 1.1, [Flash(marks[0][1], color=AMBAR, line_length=0.3, + num_lines=12, flash_radius=0.8)]) + + with self.beat(5) as b: + goto(b, 20, 1.1, [Flash(marks[1][1], color=AMBAR, line_length=0.3, + num_lines=12, flash_radius=0.8)]) + + with self.beat(6) as b: + goto(b, 30, 1.1, [Flash(marks[2][1], color=AMBAR, line_length=0.3, + num_lines=12, flash_radius=0.8)]) + atm = Text("fuera de la atmósfera", font=FONT, font_size=32, + weight=BOLD, color=CELESTE).move_to([0.9, ypos(1e8) - 0.6, 0]) + b.play(FadeIn(atm, shift=UP * 0.1), run_time=0.5) + + with self.beat(7) as b: + b.play(FadeOut(atm), run_time=0.25) + goto(b, 40, 1.2) + + with self.beat(8) as b: + goto(b, 42, 1.3) + b.play(Flash(moon_ic, color="#D9DEE8", line_length=0.55, + num_lines=18, flash_radius=1.1), run_time=0.8) + + with self.beat(9) as b: + over = Text("te pasaste de largo", font=FONT, font_size=44, weight=BOLD, color=VERDE) + over.move_to([0.75, ym - 0.95, 0]) + self.fit(over, 5.6) + b.play(FadeIn(over, shift=UP * 0.15), run_time=0.6) + b.play(Circumscribe(over, color=VERDE, buff=0.22, stroke_width=6), run_time=0.9) + + with self.beat(10) as b: + b.play(FadeOut(VGroup(axis, base, marks, moon_line, moon_ic, moon_lb, + bar, over, readout)), run_time=0.6) + t1 = self.fit(Text("crecimiento", font=FONT, font_size=74, weight=BOLD, + color=WHITE), 8.0) + t2 = self.fit(Text("EXPONENCIAL", font=FONT, font_size=90, weight=BOLD, + color=AMBAR), 8.2) + g = VGroup(t1, t2).arrange(DOWN, buff=0.3).move_to(UP * 1.6) + t3 = self.fit(Text("por eso nadie lo ve venir", font=FONT, font_size=40, + color=GRIS), 7.6).next_to(g, DOWN, buff=0.7) + b.play(FadeIn(t1, shift=UP * 0.2), run_time=0.5) + b.play(FadeIn(t2, scale=0.7), run_time=0.6) + b.play(FadeIn(t3), run_time=0.5) + + self.finish() |