From 59355909f2de9236af8168a26c70bcf6caa3b285 Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Sat, 26 Sep 2026 20:21:47 -0300 Subject: Import video pipeline as it was --- scenes/v8_reuleaux.py | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 scenes/v8_reuleaux.py (limited to 'scenes/v8_reuleaux.py') diff --git a/scenes/v8_reuleaux.py b/scenes/v8_reuleaux.py new file mode 100644 index 0000000..66b686c --- /dev/null +++ b/scenes/v8_reuleaux.py @@ -0,0 +1,158 @@ +# -*- coding: utf-8 -*- +import sys, os, math +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from manim import * +from tiktok import * + +W = 2.9 # ancho constante de las figuras +FLOOR = -0.6 # piso de la animacion de rodado + + +def reuleaux(w, bulge=1, **kw): + """Triangulo de Reuleaux: 3 arcos de radio w centrados en el vertice opuesto.""" + R = w / math.sqrt(3) + V = [R * np.array([math.cos(a), math.sin(a), 0]) + for a in (PI / 2, PI / 2 + TAU / 3, PI / 2 + 2 * TAU / 3)] + arcs = [ArcBetweenPoints(V[i], V[(i + 1) % 3], angle=bulge * PI / 3) for i in range(3)] + m = VMobject(**kw) + m.set_points(arcs[0].points) + for a in arcs[1:]: + m.append_points(a.points) + return m + + +class Reuleaux(TikTok): + NAME = "reuleaux" + + def construct(self): + self.prepare() + chip = self.chip("Geometría de la calle", AMBAR) + + with self.beat(0) as b: + tapa = VGroup( + Circle(radius=1.6, stroke_color="#7A879F", stroke_width=12, + fill_color="#1B2438", fill_opacity=1), + Circle(radius=1.25, stroke_color="#4A5878", stroke_width=5), + VGroup(*[Line(ORIGIN, RIGHT * 1.1, stroke_width=5, color="#4A5878") + .rotate(a, about_point=ORIGIN) for a in np.arange(0, TAU, TAU / 8)]), + ).move_to(UP * 3.4) + q = self.fit(Text("¿por qué son redondas?", font=FONT, font_size=52, + weight=BOLD, color=WHITE), 8.0).move_to(UP * 0.7) + b.play(FadeIn(chip, shift=DOWN * 0.3), run_time=0.45) + b.play(FadeIn(tapa, scale=0.7), run_time=0.8) + b.play(Write(q), run_time=0.9) + + with self.beat(1) as b: + ans = self.fit(Text("no se pueden caer adentro", font=FONT, font_size=46, + weight=BOLD, color=VERDE), 8.2).move_to(DOWN * 0.7) + b.play(FadeIn(ans, shift=UP * 0.15), run_time=0.7) + + # ---- la cuadrada se cae ---- + with self.beat(2) as b: + b.play(FadeOut(VGroup(tapa, q, ans)), run_time=0.4) + hole = Square(side_length=2.6, stroke_color="#4A5878", stroke_width=6, + fill_color="#05070D", fill_opacity=1).move_to(UP * 3.2) + cover = Square(side_length=2.5, stroke_color=ROSA, stroke_width=8, + fill_color="#2A1220", fill_opacity=1).move_to(UP * 3.2) + b.play(FadeIn(hole), FadeIn(cover), run_time=0.5) + b.play(Rotate(cover, PI / 4), run_time=0.7) + b.play(cover.animate.shift(DOWN * 2.3).scale(0.82).set_opacity(0.35), + run_time=0.9) + cae = Text("se cae", font=FONT, font_size=44, weight=BOLD, color=ROSA) + cae.move_to(UP * 0.35) + b.play(FadeIn(cae), run_time=0.4) + + with self.beat(3) as b: + b.play(FadeOut(VGroup(cover, cae)), run_time=0.3) + lado = Line(hole.get_corner(DL), hole.get_corner(DR), + stroke_width=8, color=CELESTE).shift(DOWN * 0.35) + diag = Line(hole.get_corner(DL), hole.get_corner(UR), stroke_width=8, color=ROSA) + l1 = Text("lado", font=FONT, font_size=34, weight=BOLD, + color=CELESTE).next_to(lado, DOWN, buff=0.12) + l2 = Text("diagonal = 1,41 × lado", font=FONT, font_size=36, weight=BOLD, + color=ROSA).move_to(UP * 0.9) + self.fit(l2, 8.0) + b.play(Create(lado), FadeIn(l1), run_time=0.6) + b.play(Create(diag), run_time=0.6) + b.play(FadeIn(l2, shift=UP * 0.15), run_time=0.6) + + # ---- el circulo mide igual en toda direccion ---- + with self.beat(4) as b: + b.play(FadeOut(VGroup(hole, lado, diag, l1, l2)), run_time=0.4) + circ = Circle(radius=W / 2, stroke_color=CELESTE, stroke_width=9, + fill_color="#0E2233", fill_opacity=1).move_to(UP * 3.0) + tr = ValueTracker(0) + cal = always_redraw(lambda: DoubleArrow( + circ.get_center() + rotate_vector(RIGHT * W / 2, tr.get_value()), + circ.get_center() - rotate_vector(RIGHT * W / 2, tr.get_value()), + buff=0, color=AMBAR, stroke_width=7, tip_length=0.22)) + b.play(FadeIn(circ, scale=0.8), run_time=0.5) + b.play(FadeIn(cal), run_time=0.3) + b.play(tr.animate.set_value(PI), run_time=max(1.0, b.floor - 1.1), + rate_func=linear) + same = Text("mide igual en toda dirección", font=FONT, font_size=38, + weight=BOLD, color=AMBAR).move_to(UP * 0.55) + self.fit(same, 8.2) + b.play(FadeIn(same), run_time=0.4) + + with self.beat(5) as b: + no = self.fit(Text("y no es la única", font=FONT, font_size=50, + weight=BOLD, color=WHITE), 8.0).move_to(DOWN * 0.7) + b.play(FadeIn(no, shift=UP * 0.15), run_time=0.7) + + # ---- aparece el Reuleaux ---- + tri = reuleaux(W, stroke_color=VERDE, stroke_width=9, + fill_color="#0C2A22", fill_opacity=1).move_to(UP * 3.0) + with self.beat(6) as b: + b.play(FadeOut(VGroup(cal, same, no)), run_time=0.3) + b.play(Transform(circ, tri), run_time=1.2) + + with self.beat(7) as b: + nom = self.fit(Text("TRIÁNGULO DE REULEAUX", font=FONT, font_size=46, + weight=BOLD, color=VERDE), 8.2).move_to(UP * 0.75) + b.play(Write(nom), run_time=1.0) + + # ---- rueda entre dos paredes ---- + with self.beat(8) as b: + b.play(FadeOut(VGroup(circ, nom)), run_time=0.4) + base = reuleaux(W, stroke_color=VERDE, stroke_width=9, + fill_color="#0C2A22", fill_opacity=1) + spin = ValueTracker(0) + + def rodando(): + s = base.copy().rotate(spin.get_value()) + s.shift(UP * (FLOOR - s.get_bottom()[1])) + return s + + rolling = always_redraw(rodando) + suelo = Line([-4.2, FLOOR, 0], [4.2, FLOOR, 0], stroke_width=7, color="#4A5878") + techo = Line([-4.2, FLOOR + W, 0], [4.2, FLOOR + W, 0], + stroke_width=7, color=AMBAR) + b.play(Create(suelo), Create(techo), run_time=0.5) + b.play(FadeIn(rolling), run_time=0.3) + b.play(spin.animate.set_value(TAU), run_time=max(1.4, b.floor - 0.8), + rate_func=linear) + + with self.beat(9) as b: + carga = RoundedRectangle(corner_radius=0.12, width=3.4, height=0.55, + stroke_width=0, fill_color=AMBAR, fill_opacity=1) + carga.move_to([0, FLOOR + W + 0.32, 0]) + nivel = self.fit(Text("la carga no sube ni baja", font=FONT, font_size=42, + weight=BOLD, color=AMBAR), 8.0).move_to(UP * 4.3) + b.play(FadeIn(carga, shift=DOWN * 0.15), FadeIn(nivel), run_time=0.6) + b.play(spin.animate.set_value(TAU * 2), run_time=max(1.2, b.floor - 0.7), + rate_func=linear) + + with self.beat(10) as b: + b.play(FadeOut(VGroup(rolling, suelo, techo, carga, nivel)), run_time=0.5) + cta = VGroup( + self.fit(Text("ahora ya sabés", font=FONT, font_size=50, + weight=BOLD, color=WHITE), 8.0), + self.fit(Text("por qué son redondas", font=FONT, font_size=54, + weight=BOLD, color=AMBAR), 8.2), + ).arrange(DOWN, buff=0.32).move_to(UP * 1.6) + b.play(FadeIn(cta[0], shift=UP * 0.15), run_time=0.5) + b.play(Write(cta[1]), run_time=0.9) + b.play(Circumscribe(cta[1], color=AMBAR, buff=0.28, stroke_width=7), run_time=0.9) + + self.finish() -- cgit v1.2.3