diff options
Diffstat (limited to 'scenes/tiktok.py')
| -rw-r--r-- | scenes/tiktok.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/scenes/tiktok.py b/scenes/tiktok.py index 7e2ad2d..584210e 100644 --- a/scenes/tiktok.py +++ b/scenes/tiktok.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -"""Base comun para los videos verticales: formato 9:16, subtitulos, -barra de progreso y un sistema de 'beats' sincronizados con el audio.""" +"""Common base for the vertical videos: 9:16 format, subtitles, +progress bar and a system of 'beats' synced with the audio.""" import json, os from contextlib import contextmanager from manim import * -# --- formato TikTok 1080x1920 ------------------------------------------------- +# --- TikTok format 1080x1920 -------------------------------------------------- if os.environ.get("DRAFT"): config.pixel_width, config.pixel_height = 540, 960 else: @@ -18,19 +18,19 @@ config.background_color = "#0B0F1A" ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) FONT = "Roboto" -AMBAR = "#FFD166" -VERDE = "#06D6A0" -ROSA = "#EF476F" -CELESTE = "#4CC9F0" -GRIS = "#8D99AE" - -GAP = 0.30 # silencio entre segmentos -SUB_Y = -4.25 # los subtitulos van arriba de la UI de TikTok +AMBER = "#FFD166" +C_GREEN = "#06D6A0" +C_PINK = "#EF476F" +C_SKY = "#4CC9F0" +C_GRAY = "#8D99AE" + +GAP = 0.30 # silence between segments +SUB_Y = -4.25 # subtitles sit above the TikTok UI TOP_Y = 6.45 class _Beat: - """Acumula el tiempo usado dentro de un segmento para poder rellenar el resto.""" + """Accumulates the time used inside a segment so the rest can be filled.""" def __init__(self, scene, floor): self.s, self.floor, self.used = scene, floor, 0.0 @@ -63,7 +63,7 @@ class _Beat: class TikTok(Scene): NAME = "" - # -- infraestructura ------------------------------------------------------ + # -- infrastructure ------------------------------------------------------- def prepare(self): with open(os.path.join(ROOT, "audio", self.NAME, "segments.json"), encoding="utf-8") as f: self.data = json.load(f) @@ -88,7 +88,7 @@ class TikTok(Scene): track = Rectangle(width=w, height=0.075, stroke_width=0, fill_color="#1B2233", fill_opacity=1).move_to(UP * (TOP_Y + 1.15)) bar = Rectangle(width=0.002, height=0.075, stroke_width=0, - fill_color=AMBAR, fill_opacity=1).move_to(track.get_left(), LEFT) + fill_color=AMBER, fill_opacity=1).move_to(track.get_left(), LEFT) self.elapsed = 0.0 total, left, y = self._expected, -w / 2, track.get_y() @@ -103,7 +103,7 @@ class TikTok(Scene): self.add(track, bar) def subtitle(self, text): - """Cambia el subtitulo sin consumir tiempo de animacion.""" + """Changes the subtitle without spending animation time.""" if self._sub: self.remove(self._sub) t = Text(text, font=FONT, font_size=44, weight=BOLD, color=WHITE, @@ -118,7 +118,7 @@ class TikTok(Scene): @contextmanager def beat(self, i, sub=True): - """Bloque sincronizado con el segmento i de audio.""" + """Block synced with audio segment i.""" if sub: self.subtitle(self.segs[i]["sub"]) b = _Beat(self, self.segs[i]["dur"]) @@ -139,8 +139,8 @@ class TikTok(Scene): json.dump({"name": self.NAME, "gap": GAP, "total": round(self.clock, 3), "beats": self.timeline}, f, indent=2) - # -- helpers visuales ----------------------------------------------------- - def chip(self, text, color=AMBAR): + # -- visual helpers ------------------------------------------------------- + def chip(self, text, color=AMBER): t = Text(text, font=FONT, font_size=34, weight=BOLD, color="#0B0F1A") box = RoundedRectangle(corner_radius=0.3, stroke_width=0, fill_color=color, fill_opacity=1, width=t.width + 0.7, height=t.height + 0.45) |