aboutsummaryrefslogtreecommitdiffstats
path: root/scenes/v5_japones.py
diff options
context:
space:
mode:
Diffstat (limited to 'scenes/v5_japones.py')
-rw-r--r--scenes/v5_japones.py160
1 files changed, 160 insertions, 0 deletions
diff --git a/scenes/v5_japones.py b/scenes/v5_japones.py
new file mode 100644
index 0000000..9b617d5
--- /dev/null
+++ b/scenes/v5_japones.py
@@ -0,0 +1,160 @@
+# -*- coding: utf-8 -*-
+import sys, os
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+from manim import *
+from tiktok import *
+
+M = 0.6 # pendiente de las familias de rectas
+XA, XB = -3.2, 3.7 # extremos de los segmentos
+C_TENS, C_UNITS = [1.2, 1.8], [-1.2] # 21 -> rectas "/"
+D_TENS, D_UNITS = [-1.2], [1.2, 1.8, 2.4] # 13 -> rectas "\"
+
+
+def pline(c):
+ return Line([XA, M * XA + c, 0], [XB, M * XB + c, 0])
+
+
+def qline(d):
+ return Line([XA, -M * XA + d, 0], [XB, -M * XB + d, 0])
+
+
+def cross(c, d):
+ x = (d - c) / (2 * M)
+ return np.array([x, M * x + c, 0])
+
+
+class Japones(TikTok):
+ NAME = "japones"
+
+ def construct(self):
+ self.prepare()
+ chip = self.chip("Multiplicar sin tablas", VERDE)
+
+ P = [pline(c) for c in C_TENS + C_UNITS]
+ Q = [qline(d) for d in D_TENS + D_UNITS]
+ for l in P:
+ l.set_stroke(AMBAR, 7)
+ for l in Q:
+ l.set_stroke(CELESTE, 7)
+
+ zonas = {
+ "izq": [cross(c, d) for c in C_TENS for d in D_TENS],
+ "med": [cross(c, d) for c in C_TENS for d in D_UNITS] +
+ [cross(c, d) for c in C_UNITS for d in D_TENS],
+ "der": [cross(c, d) for c in C_UNITS for d in D_UNITS],
+ }
+ dots = {k: VGroup(*[Dot(p, radius=0.13, color=WHITE) for p in v])
+ for k, v in zonas.items()}
+
+ fig = VGroup(*P, *Q, *dots.values())
+ fig.scale(6.15 / fig.height).move_to(UP * 2.35)
+
+ with self.beat(0) as b:
+ b.play(FadeIn(chip, shift=DOWN * 0.3), run_time=0.45)
+ hook = self.fit(Text("así se multiplica en Japón", font=FONT, font_size=50,
+ weight=BOLD, color=WHITE), 8.0).move_to(UP * 2.6)
+ b.play(Write(hook), run_time=1.0)
+
+ with self.beat(1) as b:
+ op = MathTex(r"21 \times 13", color=WHITE).scale(2.6).move_to(UP * 0.6)
+ op[0][0:2].set_color(AMBAR)
+ op[0][3:5].set_color(CELESTE)
+ b.play(FadeOut(hook), run_time=0.3)
+ b.play(Write(op), run_time=1.0)
+
+ with self.beat(2) as b:
+ b.play(op.animate.scale(0.44).move_to(DOWN * 2.75), run_time=0.6)
+ b.play(LaggedStart(*[Create(P[i]) for i in range(len(C_TENS))],
+ lag_ratio=0.35), run_time=0.85)
+ b.play(Create(P[len(C_TENS)]), run_time=0.5)
+ d2 = Text("2", font=FONT, font_size=44, weight=BOLD, color=AMBAR)
+ d2.move_to(P[0].get_end() + RIGHT * 0.45 + UP * 0.12)
+ d1 = Text("1", font=FONT, font_size=44, weight=BOLD, color=AMBAR)
+ d1.move_to(P[2].get_end() + RIGHT * 0.45 + UP * 0.12)
+ b.play(FadeIn(d2), FadeIn(d1), run_time=0.4)
+
+ with self.beat(3) as b:
+ b.play(Create(Q[0]), run_time=0.5)
+ b.play(LaggedStart(*[Create(Q[i]) for i in range(1, len(Q))],
+ lag_ratio=0.3), run_time=0.95)
+ e1 = Text("1", font=FONT, font_size=44, weight=BOLD, color=CELESTE)
+ e1.move_to(Q[0].get_start() + LEFT * 0.45 + UP * 0.12)
+ e3 = Text("3", font=FONT, font_size=44, weight=BOLD, color=CELESTE)
+ e3.move_to(Q[2].get_start() + LEFT * 0.45 + UP * 0.12)
+ b.play(FadeIn(e1), FadeIn(e3), run_time=0.4)
+
+ digs = VGroup(d2, d1, e1, e3)
+ res = {}
+ prev = []
+
+ def zona(bt, key, col, valor, texto):
+ box = SurroundingRectangle(dots[key], color=col, buff=0.34,
+ corner_radius=0.3, stroke_width=7)
+ bt.play(Create(box), run_time=0.5)
+ bt.play(LaggedStart(*[FadeIn(dd, scale=0.4) for dd in dots[key]],
+ lag_ratio=0.18), run_time=0.7)
+ lab = Text(texto, font=FONT, font_size=42, weight=BOLD, color=col)
+ lab.next_to(box, DOWN, buff=0.28)
+ self.fit(lab, 4.6)
+ if lab.get_left()[0] < -3.9:
+ lab.shift(RIGHT * (-3.9 - lab.get_left()[0]))
+ if lab.get_right()[0] > 3.9:
+ lab.shift(LEFT * (lab.get_right()[0] - 3.9))
+ anim = [FadeIn(lab, shift=UP * 0.12)]
+ if prev:
+ anim.append(FadeOut(prev[-1]))
+ bt.play(*anim, run_time=0.5)
+ prev.append(lab)
+ res[key] = (box, lab, valor)
+ return box, lab
+
+ with self.beat(4) as b:
+ bz, lz = zona(b, "izq", VERDE, 2, "2 cruces")
+
+ with self.beat(5) as b:
+ bm, lm = zona(b, "med", ROSA, 7, "6 + 1 = 7")
+
+ with self.beat(6) as b:
+ bd, ld = zona(b, "der", CELESTE, 3, "3 cruces")
+
+ with self.beat(7) as b:
+ nums = VGroup(
+ Text("2", font=FONT, font_size=96, weight=BOLD, color=VERDE),
+ Text("7", font=FONT, font_size=96, weight=BOLD, color=ROSA),
+ Text("3", font=FONT, font_size=96, weight=BOLD, color=CELESTE),
+ ).arrange(RIGHT, buff=0.55).move_to(DOWN * 1.35)
+ b.play(FadeOut(VGroup(ld, op)), run_time=0.3)
+ b.play(TransformFromCopy(dots["izq"], nums[0]),
+ TransformFromCopy(dots["med"], nums[1]),
+ TransformFromCopy(dots["der"], nums[2]), run_time=1.1)
+ total = Text("273", font=FONT, font_size=112, weight=BOLD, color=WHITE)
+ total.move_to(DOWN * 2.9)
+ b.play(TransformFromCopy(nums, total), run_time=0.9)
+
+ with self.beat(8) as b:
+ b.play(FadeOut(VGroup(*P, *Q, *dots.values(), bz, bm, bd, digs, nums)),
+ run_time=0.5)
+ check = MathTex(r"21 \times 13 = 273", color=VERDE).scale(1.9).move_to(UP * 2.4)
+ b.play(total.animate.move_to(UP * 0.2).scale(0.9), run_time=0.5)
+ b.play(Write(check), run_time=0.9)
+ b.play(Flash(check, color=VERDE, line_length=0.6, num_lines=20,
+ flash_radius=2.4), run_time=0.8)
+
+ with self.beat(9) as b:
+ b.play(FadeOut(total), run_time=0.3)
+ tip = VGroup(
+ self.fit(Text("¿una zona da más de 9?", font=FONT, font_size=46,
+ weight=BOLD, color=WHITE), 8.0),
+ self.fit(Text("llevás una a la de al lado", font=FONT, font_size=46,
+ weight=BOLD, color=AMBAR), 8.0),
+ ).arrange(DOWN, buff=0.35).move_to(DOWN * 0.6)
+ b.play(FadeIn(tip[0], shift=UP * 0.15), run_time=0.6)
+ b.play(FadeIn(tip[1], shift=UP * 0.15), run_time=0.6)
+
+ with self.beat(10) as b:
+ cta = self.fit(Text("guardalo para la tarea", font=FONT, font_size=60,
+ weight=BOLD, color=AMBAR), 8.0).move_to(DOWN * 2.6)
+ b.play(Write(cta), run_time=0.9)
+ b.play(Circumscribe(cta, color=AMBAR, buff=0.3, stroke_width=7), run_time=1.0)
+
+ self.finish()