aboutsummaryrefslogtreecommitdiffstats
path: root/scenes/overlay.py
blob: d8d735b0c94049e1187e887b0f745ca118a946f5 (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
# -*- coding: utf-8 -*-
"""Channel UI layer (chip, progress bar and subtitles) for the videos rendered
in Blender. It is rendered with --transparent and composited over the 3D, so
the style comes from the same code as the Manim videos.

  NAME=bolapeluda CHIP=Topología CHIPCOL=celeste manim --transparent ...

It also writes out/<name>_timeline.json, which the Blender script (to animate)
and build_video.py (to place the audio) read afterwards.
"""
import os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from manim import *
from tiktok import *

PALETTE = {"ambar": AMBER, "verde": C_GREEN, "rosa": C_PINK, "celeste": C_SKY}


class Overlay(TikTok):
    NAME = os.environ.get("NAME", "")

    def backdrop(self):
        return VGroup()          # the dotted background goes separately, under the 3D

    def construct(self):
        self.prepare()
        chip = self.chip(os.environ.get("CHIP", ""),
                         PALETTE[os.environ.get("CHIPCOL", "ambar")])
        self.add(chip)
        for i in range(len(self.segs)):
            with self.beat(i) as b:
                b.wait(b.floor)
        self.finish()


class Backdrop(TikTok):
    """A single frame with the dot pattern, to use as background."""
    NAME = "fondo"

    def construct(self):
        self._sub = None
        TikTok.backdrop(self)
        self.wait(0.1)