Skip to content

Commit 674d464

Browse files
committed
update example_scenes.py to use InteractiveScene
1 parent b487def commit 674d464

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

example_scenes.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Use -n <number> to skip ahead to the n'th animation of a scene.
1010

1111

12-
class OpeningManimExample(Scene):
12+
class OpeningManimExample(InteractiveScene):
1313
def construct(self):
1414
intro_words = Text("""
1515
The original motivation for manim was to
@@ -66,9 +66,10 @@ def construct(self):
6666
run_time=6,
6767
)
6868
self.wait(2)
69+
self.embed()
6970

7071

71-
class AnimatingMethods(Scene):
72+
class AnimatingMethods(InteractiveScene):
7273
def construct(self):
7374
grid = Tex(R"\pi").get_grid(10, 10, height=4)
7475
self.add(grid)
@@ -110,9 +111,10 @@ def construct(self):
110111
run_time=5,
111112
)
112113
self.wait()
114+
self.embed()
113115

114116

115-
class TextExample(Scene):
117+
class TextExample(InteractiveScene):
116118
def construct(self):
117119
# To run this scene properly, you should have "Consolas" font in your computer
118120
# for full usage, you can see https://github.com/3b1b/manim/pull/680
@@ -151,9 +153,10 @@ def construct(self):
151153
self.wait()
152154
self.play(Write(slant))
153155
self.wait()
156+
self.embed()
154157

155158

156-
class TexTransformExample(Scene):
159+
class TexTransformExample(InteractiveScene):
157160
def construct(self):
158161
# Tex to color map
159162
t2c = {
@@ -223,9 +226,10 @@ def construct(self):
223226
self.wait()
224227
self.play(TransformMatchingShapes(target, saved_source, **kw))
225228
self.wait()
229+
self.embed()
226230

227231

228-
class TexIndexing(Scene):
232+
class TexIndexing(InteractiveScene):
229233
def construct(self):
230234
# You can index into Tex mobject (or other StringMobjects) by substrings
231235
equation = Tex(R"e^{\pi i} = -1", font_size=144)
@@ -276,9 +280,10 @@ def construct(self):
276280
self.play(equation[R"\infty"].animate.set_color(RED)) # Got it!
277281
self.wait()
278282
self.play(FadeOut(equation))
283+
self.embed()
279284

280285

281-
class UpdatersExample(Scene):
286+
class UpdatersExample(InteractiveScene):
282287
def construct(self):
283288
square = Square()
284289
square.set_fill(BLUE_E, 1)
@@ -336,9 +341,10 @@ def construct(self):
336341
lambda m: m.set_width(w0 * math.sin(self.time - now) + w0)
337342
)
338343
self.wait(4 * PI)
344+
self.embed()
339345

340346

341-
class CoordinateSystemExample(Scene):
347+
class CoordinateSystemExample(InteractiveScene):
342348
def construct(self):
343349
axes = Axes(
344350
# x-axis ranges from -1 to 10, with a default step size of 1
@@ -415,9 +421,9 @@ def construct(self):
415421

416422
# Other coordinate systems you can play around with include
417423
# ThreeDAxes, NumberPlane, and ComplexPlane.
424+
self.embed()
418425

419-
420-
class GraphExample(Scene):
426+
class GraphExample(InteractiveScene):
421427
def construct(self):
422428
axes = Axes((-3, 10), (-1, 8), height=6)
423429
axes.add_coordinate_labels()
@@ -493,9 +499,10 @@ def construct(self):
493499
self.play(x_tracker.animate.set_value(4), run_time=3)
494500
self.play(x_tracker.animate.set_value(-2), run_time=3)
495501
self.wait()
502+
self.embed()
496503

497504

498-
class TexAndNumbersExample(Scene):
505+
class TexAndNumbersExample(InteractiveScene):
499506
def construct(self):
500507
axes = Axes((-3, 3), (-3, 3), unit_size=1)
501508
axes.to_edge(DOWN)
@@ -561,9 +568,10 @@ def func(x, y):
561568
ReplacementTransform(circle.copy(), new_curve),
562569
circle.animate.set_stroke(width=1, opacity=0.5),
563570
)
571+
self.embed()
564572

565573

566-
class SurfaceExample(ThreeDScene):
574+
class SurfaceExample(ThreeDScene, InteractiveScene):
567575
def construct(self):
568576
surface_text = Text("For 3d scenes, try using surfaces")
569577
surface_text.fix_in_frame()
@@ -643,9 +651,10 @@ def construct(self):
643651

644652
self.play(FadeTransform(light_text, drag_text))
645653
self.wait()
654+
self.embed()
646655

647656

648-
class InteractiveDevelopment(Scene):
657+
class InteractiveDevelopment(InteractiveScene):
649658
def construct(self):
650659
circle = Circle()
651660
circle.set_fill(BLUE, opacity=0.5)
@@ -691,7 +700,7 @@ def construct(self):
691700
always(circle.move_to, self.mouse_point)
692701

693702

694-
class ControlsExample(Scene):
703+
class ControlsExample(InteractiveScene):
695704
drag_to_pan = False
696705

697706
def setup(self):
@@ -728,7 +737,7 @@ def text_updater(old_text):
728737

729738
self.textbox.set_value("Manim")
730739
# self.wait(60)
731-
# self.embed()
740+
self.embed()
732741

733742

734743
# See https://github.com/3b1b/videos for many, many more

0 commit comments

Comments
 (0)