-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathexample.py
More file actions
329 lines (282 loc) · 11.2 KB
/
Copy pathexample.py
File metadata and controls
329 lines (282 loc) · 11.2 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
from manim import *
from manim_editor import PresentationSectionType
class Test(Scene):
def construct(self):
circle = Circle()
square = Square()
self.add(circle)
self.wait()
self.next_section()
self.add(square)
self.wait()
self.next_section()
self.remove(circle)
self.wait()
self.next_section()
self.remove(square)
self.wait()
class Tutorial(Scene):
def construct(self):
#########
# title #
#########
self.next_section("title", PresentationSectionType.NORMAL)
banner = ManimBanner()
self.play(banner.create())
self.play(banner.expand())
self.wait()
self.play(Unwrite(banner))
title = Text("Manim Editor", font_size=60).shift(2*UP)
title_ul = Underline(title)
self.play(Write(title), run_time=0.5)
text = VGroup(
Text("Press any of the usual \"next\"-keys"),
Text("like RightArrow or PageUp"),
Text("to go to the next section."),
Text("You can also use the > button above."),
).arrange(DOWN).shift(DOWN)
self.play(Write(text), Write(title_ul), run_time=0.5)
self.wait()
##################
# normal section #
##################
self.next_section("normal section", PresentationSectionType.NORMAL)
self.remove(title, title_ul, text)
dot = Dot([-4, -2, 0]).scale(3)
text = VGroup(
Text("There are four different types of sections."),
MarkupText("This is the first type, a <b>normal section</b>."),
Text("The animation plays and patiently waits"),
Text("for the speaker to finally"),
Text("get their point across."),
).arrange(DOWN).shift(UP)
self.play(FadeIn(dot), Write(text), run_time=0.5)
self.play(dot.animate.shift(8*RIGHT), run_time=2)
self.wait()
################
# back in time #
################
self.next_section("back in time", PresentationSectionType.NORMAL)
self.remove(text)
text = VGroup(
Text("You can go back in time as well. Try it!"),
Text("Don't expect any smooth"),
Text("transitions though."),
Text("If you want to start from the beginning,"),
Text("reload the page."),
).arrange(DOWN).shift(UP)
self.play(Write(text), run_time=0.5)
self.play(dot.animate.shift(4*LEFT))
self.wait()
##############
# fullscreen #
##############
self.next_section("fullscreen", PresentationSectionType.NORMAL)
self.remove(text)
text = VGroup(
Text("Your eyes hurt from the tiny video?"),
Text("Stop whining!"),
Text("Or press F to enter fullscreen."),
).arrange(DOWN)
self.play(FadeOut(dot), Write(text), run_time=0.5)
self.wait()
######################
# loop section intro #
######################
self.next_section("loop section intro", PresentationSectionType.NORMAL)
self.remove(text)
text = VGroup(
Text("Let's do something different now."),
Text("What follows is an animation from the"),
Text("Manim CE Gallery"),
Text("that I ruthlessly stole :)"),
).arrange(DOWN)
self.play(Write(text), run_time=0.5)
self.wait()
################
# loop section #
################
self.next_section("loop section", PresentationSectionType.LOOP)
self.remove(text)
text = VGroup(
Text("This is the second type,"),
MarkupText("a <b>loop section</b>."),
).arrange(DOWN).shift(2*UP)
self.play(Write(text), run_time=0.5)
circle = Circle(arc_center=[0, -2, 0], radius=1, color=YELLOW)
dot = Dot([0, -2, 0])
self.add(dot)
line = Line([3, -2, 0], [5, -2, 0])
self.add(line)
self.play(GrowFromCenter(circle))
self.play(dot.animate.shift(RIGHT))
self.play(MoveAlongPath(dot, circle), run_time=2)
######################
# skip section intro #
######################
self.next_section("skip section intro", PresentationSectionType.NORMAL)
self.remove(text, dot, line, circle)
text = VGroup(
Text("If you payed close attention,"),
Text("you might have noticed that"),
Text("the animation is...fucked."),
Text("It just cuts at the end."),
Text("Smooth transitions look different!"),
Text("Let me show you how it's done."),
).arrange(DOWN)
self.play(Write(text), run_time=0.5)
self.wait()
################
# skip section #
################
self.next_section("skip section", PresentationSectionType.SKIP)
self.remove(text)
text = VGroup(
MarkupText("This is a <b>skip section</b>"),
Text("It functions just like a normal section"),
Text("with the difference that it immediately"),
Text("continues with the next section"),
Text("once it's finished."),
).arrange(DOWN).shift(1.5*UP)
self.play(Write(text), run_time=0.5)
dot.move_to([0, -2, 0])
self.add(line)
self.play(GrowFromCenter(circle))
self.play(dot.animate.shift(RIGHT))
self.next_section("loop section after skip section", PresentationSectionType.LOOP)
self.play(MoveAlongPath(dot, circle), run_time=2)
#########################
# animation fucked again#
#########################
self.next_section("animation fucked again", PresentationSectionType.NORMAL)
self.remove(text)
text = VGroup(
Text("Let's finish the animation. Here we"),
Text("encounter another problem: The dot"),
Text("teleports when progressing to the"),
Text("next section. You didn't see it?"),
Text("Go back in time and try again."),
).arrange(DOWN).shift(1.5*UP)
self.play(Write(text), Rotating(dot, about_point=[2, -2, 0]), run_time=1.5)
self.wait()
###############################
# complete loop section intro #
###############################
self.next_section("complete loop section intro", PresentationSectionType.NORMAL)
self.remove(text, dot, circle, line)
text = VGroup(
Text("This is where"),
MarkupText("<b>complete loop section</b> come in."),
Text("They are just like loop sections."),
Text("But when the speaker continues to"),
Text("the next section, the complete loop"),
Text("section finishes before continuing."),
Text("Third time's the charm:"),
).arrange(DOWN)
self.play(Write(text), run_time=0.5)
self.wait()
#########################
# complete loop section #
#########################
self.next_section("before complete loop section", PresentationSectionType.SKIP)
self.remove(text)
text = VGroup(
Text("When you go to the next section,"),
Text("the animation finishes first."),
Text("Enjoy some smooth transitions"),
).arrange(DOWN).shift(2*UP)
dot.move_to([0, -2, 0])
self.add(line)
self.play(Write(text), GrowFromCenter(circle), run_time=0.5)
self.play(dot.animate.shift(RIGHT))
self.next_section("complete loop section", PresentationSectionType.COMPLETE_LOOP)
self.play(MoveAlongPath(dot, circle), run_time=2)
self.next_section("after complete loop section", PresentationSectionType.NORMAL)
self.play(Rotating(dot, about_point=[2, -2, 0]), run_time=1.5)
self.wait()
############
# timeline #
############
self.next_section("timeline", PresentationSectionType.NORMAL)
self.remove(text, dot, circle, line)
text = VGroup(
Text("On the left you can see the"),
Text("timeline. If you're in fullscreen,"),
Text("you have to exit it first."),
Text("To do that you can use Escape or F."),
Text("The timeline shows the names"),
Text("and types of all section. When"),
Text("you click on a section on the timeline,"),
Text("that section plays immediately."),
).arrange(DOWN)
self.play(Write(text), run_time=0.5)
self.wait()
self.next_section("skip sections and the timeline", PresentationSectionType.NORMAL)
self.remove(text)
text = VGroup(
Text("This shows another use case for"),
Text("skip sections:"),
Text("Splitting up bigger animations."),
Text("With the timeline"),
Text("you can skip to any part of it."),
).arrange(DOWN)
self.play(Write(text), run_time=0.5)
self.wait()
##########
# github #
##########
self.next_section("active development", PresentationSectionType.NORMAL)
self.remove(text)
text = VGroup(
Text("This project is still under"),
Text("active development."),
Text("If you encounter any problems"),
Text("or have good ideas for new features,"),
MarkupText("please open an <b>Issue on GitHub</b>."),
).arrange(DOWN)
self.play(Write(text), run_time=0.5)
self.wait()
self.next_section("docs", PresentationSectionType.NORMAL)
self.remove(text)
text = VGroup(
Text("On GitHub you'll find a more in-depth"),
Text("documentation. It explains some nerdy"),
Text("details about how the videos are"),
Text("being played, buffered and cached."),
Text("It also shows how to use the"),
Text("presentation API."),
Text("If you have any questions,"),
Text("this is where you should look first."),
).arrange(DOWN)
self.play(Write(text), run_time=0.5)
self.wait()
##########
# ending #
##########
self.next_section("ending", PresentationSectionType.NORMAL)
self.remove(text)
text = VGroup(
Text("You can find the code here:"),
Text("github.com/christopher-besch/"),
Text("manim_web_presenter"),
Text("And as always, thanks for watching!"),
).arrange(DOWN).shift(1*DOWN)
end = Text("The End", font_size=60).shift(2*UP)
end_ul = Underline(end)
self.play(Write(text), run_time=0.5)
self.wait()
self.play(Write(end), run_time=0.5)
self.play(Write(end_ul), run_time=0.5)
self.wait()
############
# fade out #
############
self.next_section("heli flying into the sunset; fade out", PresentationSectionType.NORMAL)
self.play(Unwrite(text), Unwrite(end), Unwrite(end_ul))
self.wait(2)
image = ImageMobject("img.jpg")
image.height = 9
self.play(FadeIn(image))
self.wait(4)
self.remove(image)
self.wait()