forked from 3b1b/manim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEBText.py
More file actions
228 lines (185 loc) · 6.75 KB
/
EBText.py
File metadata and controls
228 lines (185 loc) · 6.75 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/usr/bin/env python
from manimlib.imports import *
class WriteText(Scene):
def construct(self):
text = TextMobject("This is a regular text")
self.play(Write(text))
self.wait(3)
class AddText(Scene):
def construct(self):
text = TextMobject("This is a regular text")
self.add(text)
self.wait(3)
class Formular(Scene):
def construct(self):
formula = TexMobject("This is a formula")
self.play(Write(formula))
self.wait(3)
class TypesOfText(Scene):
def construct(self):
typesOfText = TextMobject("""
This is a regular text,
$this is a formula$,
$$this is a formula$$
""")
self.play(Write(typesOfText))
self.wait(3)
class TypesOfText2(Scene):
def construct(self):
typesOfText = TextMobject("""
This is a regular text,
$\\frac{x}{y}$,
$$x^2 + y^2 = a^2$$
""")
self.play(Write(typesOfText))
self.wait(3)
class DisplayFormula(Scene):
def construct(self):
typesOfText = TextMobject("""
This is a regular text,
$\\displaystyle \\frac{x}{y}$
$$x^2+y^2=a^2$$
""")
self.play(Write(typesOfText))
self.wait(3)
class TextInCenter(Scene):
def construct(self):
text = TextMobject("Text")
self.play(Write(text))
self.wait(3)
class TextOnTopEdge(Scene):
def construct(self):
text = TextMobject("Text")
text.to_edge(UP)
self.play(Write(text))
self.wait(3)
class TextOnBottomEdge(Scene):
def construct(self):
text = TextMobject("Text")
text.to_edge(DOWN)
self.play(Write(text))
self.wait(3)
class TextOnRightEdge(Scene):
def construct(self):
text = TextMobject("Text")
text.to_edge(RIGHT)
self.play(Write(text))
self.wait(3)
class TextOnLeftEdge(Scene):
def construct(self):
text = TextMobject("Text")
text.to_edge(LEFT)
self.play(Write(text))
self.wait(3)
class TextInUpperRightCorner(Scene):
def construct(self):
text = TextMobject("Text")
text.to_edge(UP + RIGHT)
self.play(Write(text))
self.wait(3)
class TextInLowerLeftCorner(Scene):
def construct(self):
text = TextMobject("Text")
text.to_edge(LEFT + DOWN)
self.play(Write(text))
self.wait(3)
class CustomPosition1(Scene):
def construct(self):
textM = TextMobject("Text")
textC = TextMobject("Central Text")
textM.move_to(0.25 * UP)
self.play(Write(textM), Write(textC))
self.wait(3)
class CustomPosition2(Scene):
def construct(self):
textM = TextMobject("Text")
textC = TextMobject("Central Text")
textM.move_to(1 * UP + 1 * RIGHT)
self.play(Write(textM), Write(textC))
self.wait(1)
textM.move_to(2 * DOWN + 1 * RIGHT)
self.play(Write(textM))
self.wait(3)
class RelativePosition1(Scene):
def construct(self):
textM = TextMobject("Text")
textC = TextMobject("Reference text")
textM.next_to(textC, LEFT, buff=1)
self.play(Write(textM), Write(textC))
self.wait(3)
class RelativePosition2(Scene):
def construct(self):
textM = TextMobject("Text")
textC = TextMobject("Reference text")
textM.shift(UP * 0.1)
self.play(Write(textM), Write(textC))
self.wait(3)
class RotateObject(Scene):
def construct(self):
textM = TextMobject("Text")
textC = TextMobject("Reference text")
textM.shift(UP)
textM.rotate(PI / 4) # <- Radians
self.play(Write(textM), Write(textC))
self.wait(2)
textM.rotate(PI / 4)
self.play(Write(textM))
self.wait(6)
textM.rotate(PI / 4)
self.wait(2)
textM.rotate(PI / 4)
self.wait(2)
textM.rotate(PI)
self.wait(2)
class FlipObject(Scene):
def construct(self):
textM = TextMobject("Text")
textM.flip(UP)
self.play(Write(textM))
self.wait(2)
class SizeTextOnLaTeX(Scene):
def construct(self):
textHuge = TextMobject("{ \\Huge Huge Text 012.\\#!? } Text")
texthuge = TextMobject("{ \\huge huge Text 012.\\#!? } Text")
textLARGE = TextMobject("{ \\LARGE LARGE Text 012.\\#!? } Text")
textLarge = TextMobject("{ \\Large Large Text 012.\\#!? } Text")
textlarge = TextMobject("{ \\large large Text 012.\\#!? } Text")
textNormal = TextMobject("{ \\normalsize normal Text 012.\\#!? } Text")
textsmall = TextMobject("{ \\small small Text 012.\\#!? } Text")
textfootnotesize = TextMobject(
"{ \\footnotesize footnotesize Text 012.\\#!? } Text")
textscriptsize = TextMobject(
"{ \\scriptsize scriptsize Text 012.\\#!? } Text")
texttiny = TextMobject("{ \\tiny tiny Text 012.\\#!? } Text")
textHuge.to_edge(UP)
texthuge.next_to(textHuge, DOWN, buff=0.1)
textLARGE.next_to(texthuge, DOWN, buff=0.1)
textLarge.next_to(textLARGE, DOWN, buff=0.1)
textlarge.next_to(textLarge, DOWN, buff=0.1)
textNormal.next_to(textlarge, DOWN, buff=0.1)
textsmall.next_to(textNormal, DOWN, buff=0.1)
textfootnotesize.next_to(textsmall, DOWN, buff=0.1)
textscriptsize.next_to(textfootnotesize, DOWN, buff=0.1)
texttiny.next_to(textscriptsize, DOWN, buff=0.1)
self.add(textHuge, texthuge, textLARGE, textLarge, textlarge,
textNormal, textsmall, textfootnotesize, textscriptsize,
texttiny)
self.wait(3)
class TextFonts(Scene):
def construct(self):
textNormal = TextMobject("\\textrm{Roman serif text 012.\\#!?} Text")
textItalic = TextMobject("\\textit{Italic text 012.\\#!?}Text")
textTypewriter = TextMobject(
"\\texttt{Typewritter text 012.\\#!?}Text")
textBold = TextMobject("\\textbf{Bold text 012.\\#!?}Text")
textSL = TextMobject("\\textsl{Slanted text 012.\\#!?}Text")
textSC = TextMobject("\\textsc{Small caps text 012.\\#!?}Text")
textNormal.to_edge(UP)
textItalic.next_to(textNormal, DOWN, buff=0.5)
textTypewriter.next_to(textItalic, DOWN, buff=0.5)
textBold.next_to(textTypewriter, DOWN, buff=0.5)
textSL.next_to(textBold, DOWN, buff=0.5)
textSC.next_to(textSL, DOWN, buff=0.5)
self.add(textNormal, textItalic, textTypewriter, textBold, textSL,
textSC)
self.wait(3)