-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel.py
149 lines (118 loc) · 4.38 KB
/
channel.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
from manim import *
import math
MathTex.set_default(
tex_template=TexTemplate(
preamble=r"""
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{microtype}
\DisableLigatures{encoding = *, family = * }
\linespread{1}
"""
)
)
Text.set_default(font="Orbitron")
def round_down(value, decimals):
result = round(value, decimals)
if result == int(result):
return int(result)
return result
class Car(SVGMobject):
def __init__(self, color=GRAY):
super().__init__("_car.svg")
self.set_color(color)
self.scale(0.25)
class Logo(VGroup):
def __init__(self):
mathink = Text("Mathink", weight=BOLD)
integral = MathTex(r"\int", color=RED) \
.scale(2) \
.shift(2 * LEFT + 1.5 * UP)
sq = Square(color=BLUE, side_length=1.5, fill_opacity=1).shift(0.5 * LEFT + UP)
tri = Triangle(color=GREEN, fill_opacity=1).shift(1.5 * UP + LEFT)
super().__init__(mathink, tri, integral, sq)
self[0].next_to(self[1:], DOWN)
self.center()
def animate_logo(self, run_time=2):
return AnimationGroup(Write(self[0], run_time=run_time), SpiralIn(self[1:], run_time=run_time))
class Apple(SVGMobject):
def __init__(self):
super().__init__("_apple.svg")
class Bacteria(SVGMobject):
def __init__(self):
super().__init__("_bacteria.svg")
class CancelLine(Line):
def __init__(self, mobject, color=RED):
super().__init__(DL, UR, color=RED)
self.replace(mobject, stretch=True)
class LogoScene(Scene):
# Render with manim channel.py LogoScene -r 2000,2000
def construct(self):
self.add(Logo().scale(2.5))
class BannerScene(Scene):
# Render with manim channel.py BannerScene -r 2560,1440
def construct(self):
emblema = Text("Matemáticas a tu pantalla", weight=BOLD).set_color(YELLOW)
manzanas = VGroup(*[Apple() for _ in range(6)]).scale(0.7).arrange(RIGHT)
manzanas.next_to(emblema, DOWN)
VGroup(emblema, manzanas).scale(0.7).center()
grid = NumberPlane(
background_line_style={"stroke_opacity": 0.25},
axis_config={"stroke_opacity": 0.25}
)
logo = Logo().scale(0.5).to_edge(RIGHT, buff=2 * DEFAULT_MOBJECT_TO_EDGE_BUFFER)
number_of_apples = VGroup(
Integer(len(manzanas)).scale(2),
Apple().scale(0.5)
).scale(0.7).arrange(RIGHT, buff=0.1).to_edge(LEFT, buff=2 * DEFAULT_MOBJECT_TO_EDGE_BUFFER)
self.add(grid, emblema, manzanas, logo, number_of_apples)
class Intro(Scene):
def construct(self):
logo = Logo()
self.play(logo.animate_logo())
self.wait()
class IntroVertical(Scene):
def construct(self):
# Render with manim channel.py Intro -r 1080,1920
logo = Logo().scale(2)
self.play(logo.animate_logo())
self.wait()
class InThePreviousVideo(Scene):
def construct(self):
self.camera.background_color = "#333333"
titulo = Text("En el video anterior", weight=BOLD).to_edge(UP)
rec = ScreenRectangle(stroke_color=WHITE, fill_color=BLACK, fill_opacity=1, height=5)
self.add(titulo, rec)
class InThisVideo(Scene):
def construct(self):
self.camera.background_color = "#333333"
titulo = Text("En este video veremos", weight=BOLD).to_edge(UP)
rec = ScreenRectangle(stroke_color=WHITE, fill_color=BLACK, fill_opacity=1, height=5)
self.add(titulo, rec)
class Outro(Scene):
def construct(self):
titulo = Text("¡Gracias por ver!", weight=BOLD)
titulo.to_edge(UP)
codigo_fuente = Text(
"Código fuente: https://github.com/MathinkYT/manim_videos",
t2c={"https://github.com/MathinkYT/manim_videos": YELLOW},
font_size=24
)
codigo_fuente.to_edge(DOWN)
self.play(GrowFromCenter(titulo), Write(codigo_fuente))
self.wait(18)