From 8b9a40fb07b90f0f3435b4f73565cac6f4682f36 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Sun, 20 Sep 2020 00:12:21 +0200 Subject: [PATCH 01/34] #added some examples to the camera scene --- docs/source/examples/camera_settings.rst | 125 ++++++++++++++++++++--- 1 file changed, 113 insertions(+), 12 deletions(-) diff --git a/docs/source/examples/camera_settings.rst b/docs/source/examples/camera_settings.rst index 0f1df6a412..5c335d87af 100644 --- a/docs/source/examples/camera_settings.rst +++ b/docs/source/examples/camera_settings.rst @@ -1,18 +1,119 @@ Camera Settings ================================= -.. manim:: TestZoom1 +.. manim:: Example1 :quality: medium - class TestZoom1(ZoomedScene): - CONFIG = { - "zoomed_camera_frame_starting_position": [0, 0, 0], - "zoomed_display_corner": [0, 0, 0], - "zoomed_display_height": config['frame_height'], - "zoomed_display_width": config['frame_width'], - "zoom_factor": 0.1, - } + class Example1(MovingCameraScene): def construct(self): - self.activate_zooming(animate=True) - d = Dot() - self.add(d) + text = Text("Hello World") + self.add(text) + self.play(self.camera_frame.set_width, text.get_width() * 1.2) + self.wait() + +.. manim:: Example2a + :quality: medium + + class Example2a(MovingCameraScene): + def construct(self): + text = Text("Hello World").set_color(BLUE) + self.add(text) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width, text.get_width() * 1.2) + self.wait(0.3) + self.play(Restore(self.camera_frame)) + +.. manim:: Example2b + :quality: medium + + class Example2b(MovingCameraScene): + def construct(self): + text = Text("Hello World").set_color(BLUE) + self.add(text) + self.play(self.camera_frame.set_width, text.get_width() * 1.2) + self.wait(0.3) + self.play(self.camera_frame.set_width, 14) + + +.. manim:: Example3 + :quality: medium + + class Example3(MovingCameraScene): + def construct(self): + s = Square(color=RED, fill_opacity=0.5).move_to(2 * LEFT) + t = Triangle(color=GREEN, fill_opacity=0.5).move_to(2 * RIGHT) + self.add(s, t) + self.play(self.camera_frame.move_to, s) + self.wait(0.3) + self.play(self.camera_frame.move_to, t) + +.. manim:: Example4 + :quality: medium + + class Example4(MovingCameraScene): + def construct(self): + s = Square(color=BLUE, fill_opacity=0.5).move_to(2 * LEFT) + t = Triangle(color=YELLOW, fill_opacity=0.5).move_to(2 * RIGHT) + self.add(s, t) + self.play(self.camera_frame.move_to, s, + self.camera_frame.set_width,s.get_width()*2) + self.wait(0.3) + self.play(self.camera_frame.move_to, t, + self.camera_frame.set_width,t.get_width()*2) + + self.play(self.camera_frame.move_to, ORIGIN, + self.camera_frame.set_width,14) + +.. manim:: Example5 + :quality: medium + + class Example5(GraphScene, MovingCameraScene): + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + def construct(self): + self.camera_frame.save_state() + self.setup_axes(animate=False) + graph = self.get_graph(lambda x: np.sin(x), + color=WHITE, + x_min=0, + x_max=3 * PI + ) + dot_at_start_graph = Dot().move_to(graph.points[0]) + dot_at_end_grap = Dot().move_to(graph.points[-1]) + self.add(graph, dot_at_end_grap, dot_at_start_graph) + self.play(self.camera_frame.scale, 0.5, self.camera_frame.move_to, dot_at_start_graph) + self.play(self.camera_frame.move_to, dot_at_end_grap) + self.play(Restore(self.camera_frame)) + self.wait() + +.. manim:: Example6 + :quality: medium + + class Example6(GraphScene, MovingCameraScene): + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + def construct(self): + self.camera_frame.save_state() + self.setup_axes(animate=False) + graph = self.get_graph(lambda x: np.sin(x), + color=BLUE, + x_min=0, + x_max=3 * PI + ) + moving_dot = Dot().move_to(graph.points[0]).set_color(ORANGE) + + dot_at_start_graph = Dot().move_to(graph.points[0]) + dot_at_end_grap = Dot().move_to(graph.points[-1]) + self.add(graph, dot_at_end_grap, dot_at_start_graph, moving_dot) + self.play( self.camera_frame.scale,0.5,self.camera_frame.move_to,moving_dot) + + def update_curve(mob): + mob.move_to(moving_dot.get_center()) + + self.camera_frame.add_updater(update_curve) + self.play(MoveAlongPath(moving_dot, graph, rate_func=linear)) + self.camera_frame.remove_updater(update_curve) + + self.play(Restore(self.camera_frame)) \ No newline at end of file From 219c8f6ec6989301828443ef23256f5c11303b5b Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Sun, 20 Sep 2020 00:58:12 +0200 Subject: [PATCH 02/34] #added 3 ZoomedScene examples --- docs/source/examples/camera_settings.rst | 107 +++++++++++++++++- .../examplesspython/zoomed_with_rect_01.py | 22 ++++ .../examplesspython/zoomed_with_rect_02.py | 35 ++++++ .../examplesspython/zoomed_with_rect_03.py | 73 ++++++++++++ 4 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 docs/source/examplesspython/zoomed_with_rect_01.py create mode 100644 docs/source/examplesspython/zoomed_with_rect_02.py create mode 100644 docs/source/examplesspython/zoomed_with_rect_03.py diff --git a/docs/source/examples/camera_settings.rst b/docs/source/examples/camera_settings.rst index 5c335d87af..3193dbc81e 100644 --- a/docs/source/examples/camera_settings.rst +++ b/docs/source/examples/camera_settings.rst @@ -116,4 +116,109 @@ Camera Settings self.play(MoveAlongPath(moving_dot, graph, rate_func=linear)) self.camera_frame.remove_updater(update_curve) - self.play(Restore(self.camera_frame)) \ No newline at end of file + self.play(Restore(self.camera_frame)) + + +Note: ZoomedScene is derived class of MovingCameraScene, +so one can use all functionality that were used before in the MovingCameraScene examples. + +.. manim:: ExampleZoom1 + :quality: medium + + class ExampleZoom1(ZoomedScene): + def construct(self): + dot = Dot().set_color(GREEN) + self.add(dot) + self.wait(1) + self.activate_zooming(animate=False) + self.wait(1) + self.play(dot.shift, LEFT) + +.. manim:: ExampleZoom2 + :quality: medium + + class ExampleZoom2(ZoomedScene): + CONFIG = { + "zoom_factor": 0.3, + "zoomed_display_height": 1, + "zoomed_display_width": 3, + "image_frame_stroke_width": 20, + "zoomed_camera_config": { + "default_frame_stroke_width": 3, + }, + } + def construct(self): + dot = Dot().set_color(GREEN) + sq = Circle(fill_opacity=1, radius=0.2).next_to(dot, RIGHT) + self.add(dot, sq) + self.wait(1) + self.activate_zooming(animate=False) + self.wait(1) + self.play(dot.shift, LEFT * 0.3) + + self.play(self.zoomed_camera.frame.scale, 4) + self.play(self.zoomed_camera.frame.shift, 0.5 * DOWN) + + +.. manim:: ExampleZoom3 + :quality: medium + + class ExampleZoom3(ZoomedScene): + CONFIG = { + "zoom_factor": 0.3, + "zoomed_display_height": 1, + "zoomed_display_width": 6, + "image_frame_stroke_width": 20, + "zoomed_camera_config": { + "default_frame_stroke_width": 3, + }, + } + + def construct(self): + dot = Dot().shift(UL * 2) + image = ImageMobject(np.uint8([[0, 100, 30, 200], + [255, 0, 5, 33]])) + image.set_height(7) + frame_text = TextMobject("Frame", color=PURPLE).scale(1.4) + zoomed_camera_text = TextMobject("Zoomed camera", color=RED).scale(1.4) + + self.add(image, dot) + zoomed_camera = self.zoomed_camera + zoomed_display = self.zoomed_display + frame = zoomed_camera.frame + zoomed_display_frame = zoomed_display.display_frame + + frame.move_to(dot) + frame.set_color(PURPLE) + zoomed_display_frame.set_color(RED) + zoomed_display.shift(DOWN) + + zd_rect = BackgroundRectangle(zoomed_display, fill_opacity=0, buff=MED_SMALL_BUFF) + self.add_foreground_mobject(zd_rect) + + unfold_camera = UpdateFromFunc(zd_rect, lambda rect: rect.replace(zoomed_display)) + + frame_text.next_to(frame, DOWN) + + self.play(ShowCreation(frame), FadeInFromDown(frame_text)) + self.activate_zooming() + + self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera) + zoomed_camera_text.next_to(zoomed_display_frame, DOWN) + self.play(FadeInFromDown(zoomed_camera_text)) + # Scale in x y z + scale_factor = [0.5, 1.5, 0] + self.play( + frame.scale, scale_factor, + zoomed_display.scale, scale_factor, + FadeOut(zoomed_camera_text), + FadeOut(frame_text) + ) + self.wait() + self.play(ScaleInPlace(zoomed_display, 2)) + self.wait() + self.play(frame.shift, 2.5 * DOWN) + self.wait() + self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera, rate_func=lambda t: smooth(1 - t)) + self.play(Uncreate(zoomed_display_frame), FadeOut(frame)) + self.wait() \ No newline at end of file diff --git a/docs/source/examplesspython/zoomed_with_rect_01.py b/docs/source/examplesspython/zoomed_with_rect_01.py new file mode 100644 index 0000000000..dbebf337ae --- /dev/null +++ b/docs/source/examplesspython/zoomed_with_rect_01.py @@ -0,0 +1,22 @@ +from manim import * + + +class ExampleZoom1(ZoomedScene): + def construct(self): + dot = Dot().set_color(GREEN) + self.add(dot) + self.wait(1) + self.activate_zooming(animate=False) + self.wait(1) + self.play(dot.shift, LEFT) + + +import os; +import sys +from pathlib import Path + +if __name__ == "__main__": + project_path = Path(sys.path[1]).parent + script_name = f"{Path(__file__).resolve()}" + os.system( + f"manim -m --custom_folders --disable_caching -p -c 'BLACK' --config_file '{project_path}/manim_settings.cfg' " + script_name) diff --git a/docs/source/examplesspython/zoomed_with_rect_02.py b/docs/source/examplesspython/zoomed_with_rect_02.py new file mode 100644 index 0000000000..1ca0e469dd --- /dev/null +++ b/docs/source/examplesspython/zoomed_with_rect_02.py @@ -0,0 +1,35 @@ +from manim import * + + +class ExampleZoom2(ZoomedScene): + CONFIG = { + "zoom_factor": 0.3, + "zoomed_display_height": 1, + "zoomed_display_width": 3, + "image_frame_stroke_width": 20, + "zoomed_camera_config": { + "default_frame_stroke_width": 3, + }, + } + def construct(self): + dot = Dot().set_color(GREEN) + sq = Circle(fill_opacity=1, radius=0.2).next_to(dot, RIGHT) + self.add(dot, sq) + self.wait(1) + self.activate_zooming(animate=False) + self.wait(1) + self.play(dot.shift, LEFT * 0.3) + + self.play(self.zoomed_camera.frame.scale, 4) + self.play(self.zoomed_camera.frame.shift, 0.5 * DOWN) + + +import os; +import sys +from pathlib import Path + +if __name__ == "__main__": + project_path = Path(sys.path[1]).parent + script_name = f"{Path(__file__).resolve()}" + os.system( + f"manim -m --custom_folders --disable_caching -p -c 'BLACK' --config_file '{project_path}/manim_settings.cfg' " + script_name) diff --git a/docs/source/examplesspython/zoomed_with_rect_03.py b/docs/source/examplesspython/zoomed_with_rect_03.py new file mode 100644 index 0000000000..e56875d7a5 --- /dev/null +++ b/docs/source/examplesspython/zoomed_with_rect_03.py @@ -0,0 +1,73 @@ +from manim import * + + +class ExampleZoom3(ZoomedScene): + CONFIG = { + "zoom_factor": 0.3, + "zoomed_display_height": 1, + "zoomed_display_width": 6, + "image_frame_stroke_width": 20, + "zoomed_camera_config": { + "default_frame_stroke_width": 3, + }, + } + + def construct(self): + dot = Dot().shift(UL * 2) + image = ImageMobject(np.uint8([[0, 100, 30, 200], + [255, 0, 5, 33]])) + image.set_height(7) + frame_text = TextMobject("Frame", color=PURPLE).scale(1.4) + zoomed_camera_text = TextMobject("Zoomed camera", color=RED).scale(1.4) + + self.add(image, dot) + zoomed_camera = self.zoomed_camera + zoomed_display = self.zoomed_display + frame = zoomed_camera.frame + zoomed_display_frame = zoomed_display.display_frame + + frame.move_to(dot) + frame.set_color(PURPLE) + zoomed_display_frame.set_color(RED) + zoomed_display.shift(DOWN) + + zd_rect = BackgroundRectangle(zoomed_display, fill_opacity=0, buff=MED_SMALL_BUFF) + self.add_foreground_mobject(zd_rect) + + unfold_camera = UpdateFromFunc(zd_rect, lambda rect: rect.replace(zoomed_display)) + + frame_text.next_to(frame, DOWN) + + self.play(ShowCreation(frame), FadeInFromDown(frame_text)) + self.activate_zooming() + + self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera) + zoomed_camera_text.next_to(zoomed_display_frame, DOWN) + self.play(FadeInFromDown(zoomed_camera_text)) + # Scale in x y z + scale_factor = [0.5, 1.5, 0] + self.play( + frame.scale, scale_factor, + zoomed_display.scale, scale_factor, + FadeOut(zoomed_camera_text), + FadeOut(frame_text) + ) + self.wait() + self.play(ScaleInPlace(zoomed_display, 2)) + self.wait() + self.play(frame.shift, 2.5 * DOWN) + self.wait() + self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera, rate_func=lambda t: smooth(1 - t)) + self.play(Uncreate(zoomed_display_frame), FadeOut(frame)) + self.wait() + + +import os; +import sys +from pathlib import Path + +if __name__ == "__main__": + project_path = Path(sys.path[1]).parent + script_name = f"{Path(__file__).resolve()}" + os.system( + f"manim -l --custom_folders --disable_caching -p -c 'BLACK' --config_file '{project_path}/manim_settings.cfg' " + script_name) From e9621873781a039ed44f4e32981129b41f491717 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Sun, 20 Sep 2020 01:01:07 +0200 Subject: [PATCH 03/34] #removed accidentally added files --- .../examplesspython/zoomed_with_rect_01.py | 22 ------ .../examplesspython/zoomed_with_rect_02.py | 35 --------- .../examplesspython/zoomed_with_rect_03.py | 73 ------------------- 3 files changed, 130 deletions(-) delete mode 100644 docs/source/examplesspython/zoomed_with_rect_01.py delete mode 100644 docs/source/examplesspython/zoomed_with_rect_02.py delete mode 100644 docs/source/examplesspython/zoomed_with_rect_03.py diff --git a/docs/source/examplesspython/zoomed_with_rect_01.py b/docs/source/examplesspython/zoomed_with_rect_01.py deleted file mode 100644 index dbebf337ae..0000000000 --- a/docs/source/examplesspython/zoomed_with_rect_01.py +++ /dev/null @@ -1,22 +0,0 @@ -from manim import * - - -class ExampleZoom1(ZoomedScene): - def construct(self): - dot = Dot().set_color(GREEN) - self.add(dot) - self.wait(1) - self.activate_zooming(animate=False) - self.wait(1) - self.play(dot.shift, LEFT) - - -import os; -import sys -from pathlib import Path - -if __name__ == "__main__": - project_path = Path(sys.path[1]).parent - script_name = f"{Path(__file__).resolve()}" - os.system( - f"manim -m --custom_folders --disable_caching -p -c 'BLACK' --config_file '{project_path}/manim_settings.cfg' " + script_name) diff --git a/docs/source/examplesspython/zoomed_with_rect_02.py b/docs/source/examplesspython/zoomed_with_rect_02.py deleted file mode 100644 index 1ca0e469dd..0000000000 --- a/docs/source/examplesspython/zoomed_with_rect_02.py +++ /dev/null @@ -1,35 +0,0 @@ -from manim import * - - -class ExampleZoom2(ZoomedScene): - CONFIG = { - "zoom_factor": 0.3, - "zoomed_display_height": 1, - "zoomed_display_width": 3, - "image_frame_stroke_width": 20, - "zoomed_camera_config": { - "default_frame_stroke_width": 3, - }, - } - def construct(self): - dot = Dot().set_color(GREEN) - sq = Circle(fill_opacity=1, radius=0.2).next_to(dot, RIGHT) - self.add(dot, sq) - self.wait(1) - self.activate_zooming(animate=False) - self.wait(1) - self.play(dot.shift, LEFT * 0.3) - - self.play(self.zoomed_camera.frame.scale, 4) - self.play(self.zoomed_camera.frame.shift, 0.5 * DOWN) - - -import os; -import sys -from pathlib import Path - -if __name__ == "__main__": - project_path = Path(sys.path[1]).parent - script_name = f"{Path(__file__).resolve()}" - os.system( - f"manim -m --custom_folders --disable_caching -p -c 'BLACK' --config_file '{project_path}/manim_settings.cfg' " + script_name) diff --git a/docs/source/examplesspython/zoomed_with_rect_03.py b/docs/source/examplesspython/zoomed_with_rect_03.py deleted file mode 100644 index e56875d7a5..0000000000 --- a/docs/source/examplesspython/zoomed_with_rect_03.py +++ /dev/null @@ -1,73 +0,0 @@ -from manim import * - - -class ExampleZoom3(ZoomedScene): - CONFIG = { - "zoom_factor": 0.3, - "zoomed_display_height": 1, - "zoomed_display_width": 6, - "image_frame_stroke_width": 20, - "zoomed_camera_config": { - "default_frame_stroke_width": 3, - }, - } - - def construct(self): - dot = Dot().shift(UL * 2) - image = ImageMobject(np.uint8([[0, 100, 30, 200], - [255, 0, 5, 33]])) - image.set_height(7) - frame_text = TextMobject("Frame", color=PURPLE).scale(1.4) - zoomed_camera_text = TextMobject("Zoomed camera", color=RED).scale(1.4) - - self.add(image, dot) - zoomed_camera = self.zoomed_camera - zoomed_display = self.zoomed_display - frame = zoomed_camera.frame - zoomed_display_frame = zoomed_display.display_frame - - frame.move_to(dot) - frame.set_color(PURPLE) - zoomed_display_frame.set_color(RED) - zoomed_display.shift(DOWN) - - zd_rect = BackgroundRectangle(zoomed_display, fill_opacity=0, buff=MED_SMALL_BUFF) - self.add_foreground_mobject(zd_rect) - - unfold_camera = UpdateFromFunc(zd_rect, lambda rect: rect.replace(zoomed_display)) - - frame_text.next_to(frame, DOWN) - - self.play(ShowCreation(frame), FadeInFromDown(frame_text)) - self.activate_zooming() - - self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera) - zoomed_camera_text.next_to(zoomed_display_frame, DOWN) - self.play(FadeInFromDown(zoomed_camera_text)) - # Scale in x y z - scale_factor = [0.5, 1.5, 0] - self.play( - frame.scale, scale_factor, - zoomed_display.scale, scale_factor, - FadeOut(zoomed_camera_text), - FadeOut(frame_text) - ) - self.wait() - self.play(ScaleInPlace(zoomed_display, 2)) - self.wait() - self.play(frame.shift, 2.5 * DOWN) - self.wait() - self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera, rate_func=lambda t: smooth(1 - t)) - self.play(Uncreate(zoomed_display_frame), FadeOut(frame)) - self.wait() - - -import os; -import sys -from pathlib import Path - -if __name__ == "__main__": - project_path = Path(sys.path[1]).parent - script_name = f"{Path(__file__).resolve()}" - os.system( - f"manim -l --custom_folders --disable_caching -p -c 'BLACK' --config_file '{project_path}/manim_settings.cfg' " + script_name) From ab0b262c20aaa459eef31bcb2cec7483524b780f Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Sun, 20 Sep 2020 15:12:05 +0200 Subject: [PATCH 04/34] #added updater examples --- docs/source/examples/animations.rst | 103 +++++++++++++++++++++++++--- 1 file changed, 95 insertions(+), 8 deletions(-) diff --git a/docs/source/examples/animations.rst b/docs/source/examples/animations.rst index 7dea2d1b64..40f7c91615 100644 --- a/docs/source/examples/animations.rst +++ b/docs/source/examples/animations.rst @@ -15,13 +15,100 @@ Updaters class Updater1Example(Scene): def construct(self): - curve_reference = Line(ORIGIN, LEFT).set_color(GREEN) - self.add(curve_reference) + def my_rotation_updater(mobj,dt): + mobj.rotate_about_origin(dt) + line_reference = Line(ORIGIN, LEFT).set_color(WHITE) + line_moving = Line(ORIGIN, LEFT).set_color(BLUE) + line_moving.add_updater(my_rotation_updater) + self.add(line_reference, line_moving) + self.wait(PI) - def update_curve(mob, dt): - mob.rotate_about_origin(dt) +.. manim:: Updater2Example + :quality: medium - curve2 = Line(ORIGIN, LEFT) - curve2.add_updater(update_curve) - self.add(curve_reference, curve2) - self.wait(PI) + class Updater2Example(Scene): + def construct(self): + def updater_forth(mobj, dt): + mobj.rotate_about_origin(dt) + def updater_back(mobj, dt): + mobj.rotate_about_origin(-dt) + line_reference = Line(ORIGIN, LEFT).set_color(WHITE) + line_moving = Line(ORIGIN, LEFT).set_color(YELLOW) + line_moving.add_updater(updater_forth) + self.add(line_reference, line_moving) + self.wait(2) + line_moving.remove_updater(updater_forth) + line_moving.add_updater(updater_back) + self.wait(2) + line_moving.remove_updater(updater_back) + self.wait(0.5) + +.. manim:: Example3 + :quality: medium + + class Example3(Scene): + def construct(self): + number_line = NumberLine() ##with all your parameters and stuff + pointer = Vector(DOWN) + label = MathTex("x").add_updater(lambda m: m.next_to(pointer, UP)) + + pointer_value = ValueTracker(0) + pointer.add_updater( + lambda m: m.next_to( number_line.n2p(pointer_value.get_value()), UP) + ) + self.add(number_line, pointer, label) + self.play(pointer_value.set_value, 5) + self.wait() + self.play(pointer_value.set_value, 3) + +.. manim:: Example4 + :quality: medium + + class Example4(Scene): + def construct(self): + path = VMobject() + dot = Dot() + path.set_points_as_corners([dot.get_center(), dot.get_center()]) + def update_path(path): + previus_path = path.copy() + previus_path.add_points_as_corners([dot.get_center()]) + path.become(previus_path) + path.add_updater(update_path) + self.add(path, dot) + self.play(Rotating(dot, radians=PI, about_point=RIGHT, run_time=2)) + self.wait() + self.play(dot.shift, UP) + self.play(dot.shift, LEFT) + self.wait() + +.. manim:: Example1ValTracker + :quality: medium + + class Example1ValTracker(Scene): + def construct(self): + dot_disp = Dot().set_color(RED) + self.add(dot_disp) + tick_start = 1 + tick_end = 2 + val_tracker = ValueTracker(tick_start) + def dot_updater(mob): + mob.set_y(val_tracker.get_value()) + dot_disp.add_updater(dot_updater) + self.play(val_tracker.set_value, tick_end, rate_func=linear) + self.wait() + +.. manim:: Example2ValTracker + :quality: medium + + class Example2ValTracker(Scene): + def construct(self): + tick_start = 0 + tick_end = 2 * PI + val_tracker = ValueTracker(tick_start) + def my_rotation_updater(mobj): + mobj.rotate_about_origin(1 / 30) # be careful: This is framerate dependent! + line_reference = Line(ORIGIN, LEFT).set_color(WHITE) + line_moving = Line(ORIGIN, LEFT).set_color(ORANGE) + line_moving.add_updater(my_rotation_updater) + self.add(line_reference, line_moving) + self.play(val_tracker.set_value, tick_end, run_time=PI) \ No newline at end of file From f207cba30336c6bc7ea87787feeb590c177c4870 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 21 Sep 2020 11:08:21 +0200 Subject: [PATCH 05/34] #added text examples --- docs/source/examples/text.rst | 121 ++++++++++++++++++++++++++++++++-- 1 file changed, 117 insertions(+), 4 deletions(-) diff --git a/docs/source/examples/text.rst b/docs/source/examples/text.rst index f9813a57c1..d0783bf3c0 100644 --- a/docs/source/examples/text.rst +++ b/docs/source/examples/text.rst @@ -1,12 +1,125 @@ Text ================================= -.. manim:: Text1 +.. manim:: Example1Text :quality: medium :save_last_frame: - class Text1(Scene): + class Example1Text(Scene): def construct(self): - t = TextMobject("Hello World") - self.add(t) + text = Text('Hello world').scale(3) + self.add(text) +.. manim:: Example2Text + :quality: medium + :save_last_frame: + + class Example2Text(Scene): + def construct(self): + text = Text('Hello world', color=BLUE).scale(3) + self.add(text) + + +.. manim:: Example3Text + :quality: medium + :save_last_frame: + + class Example3Text(Scene): + def construct(self): + text = Text('Hello world', gradient=(BLUE, GREEN)).scale(3) + self.add(text) + + +.. manim:: Example4Text + :quality: medium + :save_last_frame: + + class Example4Text(Scene): + def construct(self): + text = Text('Hello world', t2g={'world':(BLUE, GREEN)}).scale(3) + self.add(text) + +.. manim:: Example5Text + :quality: medium + :save_last_frame: + + class Example5Text(Scene): + def construct(self): + text = Text('Hello world', font='Source Han Sans').scale(3) + self.add(text) + +.. manim:: Example6Text + :quality: medium + :save_last_frame: + + class Example6Text(Scene): + def construct(self): + text = Text('Hello world', t2f={'world':'Forte'}).scale(3) + self.add(text) + +.. manim:: Example6Text + :quality: medium + :save_last_frame: + + class Example6Text(Scene): + def construct(self): + text = Text('Hello world', slant=ITALIC).scale(3) + self.add(text) + +.. manim:: Example7Text + :quality: medium + :save_last_frame: + + class Example7Text(Scene): + def construct(self): + text = Text('Hello world!', t2s={'world':ITALIC}).scale(3) + self.add(text) + +.. manim:: Example8Text + :quality: medium + :save_last_frame: + + class Example8Text(Scene): + def construct(self): + text = Text('Hello world', weight=BOLD).scale(3) + self.add(text) + +.. manim:: Example9Text + :quality: medium + :save_last_frame: + + class Example9Text(Scene): + def construct(self): + text = Text('Hello world', t2w={'world':BOLD}).scale(3) + self.add(text) + +.. manim:: Example10Text + :quality: medium + :save_last_frame: + + class Example10Text(Scene): + def construct(self): + text = Text('Hello', size=0.3).scale(3) + self.add(text) + +.. manim:: Example11Text + :quality: medium + :save_last_frame: + + class Example11Text(Scene): + def construct(self): + text = Text('Hello\nWorld', lsh=1.5).scale(3) + self.add(text) + +.. manim:: Example12Text + :quality: medium + :save_last_frame: + + class Example12Text(Scene): + def construct(self): + text = Text( + 'Google', + t2c={'[:1]':'#3174f0', '[1:2]':'#e53125', + '[2:3]':'#fbb003', '[3:4]':'#3174f0', + '[4:5]':'#269a43', '[5:]':'#e53125', }).scale(3) + self.add(text) \ No newline at end of file From ff6ef7b923a3e637f12e6f6b6de69455d3adbef2 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 21 Sep 2020 11:33:12 +0200 Subject: [PATCH 06/34] #renamed example --- docs/source/examples/text.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/source/examples/text.rst b/docs/source/examples/text.rst index d0783bf3c0..8141818b6b 100644 --- a/docs/source/examples/text.rst +++ b/docs/source/examples/text.rst @@ -48,11 +48,11 @@ Text text = Text('Hello world', font='Source Han Sans').scale(3) self.add(text) -.. manim:: Example6Text +.. manim:: Example5bText :quality: medium :save_last_frame: - class Example6Text(Scene): + class Example5bText(Scene): def construct(self): text = Text('Hello world', t2f={'world':'Forte'}).scale(3) self.add(text) @@ -122,4 +122,8 @@ Text t2c={'[:1]':'#3174f0', '[1:2]':'#e53125', '[2:3]':'#fbb003', '[3:4]':'#3174f0', '[4:5]':'#269a43', '[5:]':'#e53125', }).scale(3) - self.add(text) \ No newline at end of file + self.add(text) + +`Text` works also with other languages like `你好` `こんにちは` `안녕하세요` +Be sure you have the font that supports those languages! + From 2e0df5093aabaaae8a0fc4ec7269092b4fc9b6d4 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 21 Sep 2020 12:03:27 +0200 Subject: [PATCH 07/34] #added 3d example with other light source --- docs/source/examples/3d.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index e6614c576a..2c12df71e8 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -19,3 +19,21 @@ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, sphere) +.. manim:: Example3DNo2 + :quality: medium + :save_last_frame: + + class Example3DNo2(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + sphere = ParametricSurface( + lambda u, v: np.array([ + 1.5 * np.cos(u) * np.cos(v), + 1.5 * np.cos(u) * np.sin(v), + 1.5 * np.sin(u) + ]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2, + checkerboard_colors=[RED_D, RED_E], resolution=(15, 32) + ) + self.camera.light_source.move_to(3*IN) + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(axes, sphere) \ No newline at end of file From 494e57c08c84cde1accc2745f5fd016cd0905df3 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 21 Sep 2020 12:20:12 +0200 Subject: [PATCH 08/34] #added imagemobject examples --- docs/source/examples/shapes.rst | 30 +++++++++++++++++++++++++++++- docs/source/examples/text.rst | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/source/examples/shapes.rst b/docs/source/examples/shapes.rst index 88888e1077..f0508c4b6c 100644 --- a/docs/source/examples/shapes.rst +++ b/docs/source/examples/shapes.rst @@ -1,7 +1,7 @@ Shapes ================================= -.. manim:: Shape1 +.. manim:: Example1Shape :quality: medium :save_last_frame: @@ -16,3 +16,31 @@ Shapes t.next_to(c, DOWN) self.add(d, c, s, t) self.wait(1) + +.. manim:: Example1ImageFromArray + :quality: medium + :save_last_frame: + + class Example1ImageFromArray(Scene): + def construct(self): + image = ImageMobject(np.uint8([[0, 100, 30, 200], + [255, 0, 5, 33]])) + image.set_height(7) + self.add(image) + +.. manim:: Example1ImageFromArray + :quality: medium + :save_last_frame: + + class Example2ImageFromFile(Scene): + def construct(self): + # these four lines, when you want to import an image from the web + import requests + from PIL import Image + img = Image.open(requests.get("https://raw.githubusercontent.com/ManimCommunity/manim/master/logo/cropped.png", + stream=True).raw) + img_mobject = ImageMobject(img) + # this line, when you want to import your Image on your machine + # img_mobject = ImageMobject("") + img_mobject.scale(3) + self.add(img_mobject) \ No newline at end of file diff --git a/docs/source/examples/text.rst b/docs/source/examples/text.rst index 8141818b6b..20d5322d01 100644 --- a/docs/source/examples/text.rst +++ b/docs/source/examples/text.rst @@ -124,6 +124,6 @@ Text '[4:5]':'#269a43', '[5:]':'#e53125', }).scale(3) self.add(text) -`Text` works also with other languages like `你好` `こんにちは` `안녕하세요` +`Text` works also with other languages like `你好` or `こんにちは` or `안녕하세요` or `مرحبا بالعالم`. Be sure you have the font that supports those languages! From b9325040774e1cdeafe4c4d4601d0a09809061af Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 21 Sep 2020 12:35:27 +0200 Subject: [PATCH 09/34] # added one line of code --- docs/source/examples/shapes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/examples/shapes.rst b/docs/source/examples/shapes.rst index f0508c4b6c..087dbea1dd 100644 --- a/docs/source/examples/shapes.rst +++ b/docs/source/examples/shapes.rst @@ -5,7 +5,7 @@ Shapes :quality: medium :save_last_frame: - class Shape1(Scene): + class Example1Shape(Scene): def construct(self): d = Dot() c = Circle() From 29c1539c5e3eda366a9459e28395547b20165275 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 21 Sep 2020 13:07:57 +0200 Subject: [PATCH 10/34] # small fix --- docs/source/examples/shapes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/examples/shapes.rst b/docs/source/examples/shapes.rst index 087dbea1dd..9ac281f319 100644 --- a/docs/source/examples/shapes.rst +++ b/docs/source/examples/shapes.rst @@ -28,7 +28,7 @@ Shapes image.set_height(7) self.add(image) -.. manim:: Example1ImageFromArray +.. manim:: Example2ImageFromFile :quality: medium :save_last_frame: From 436ea3ccdb1b70aa7251a0eb795bc0f00dc502d6 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 11:32:55 +0200 Subject: [PATCH 11/34] # added 3d examples --- docs/source/examples/3d.rst | 46 ++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index 2c12df71e8..f0f77d8fb7 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -36,4 +36,48 @@ ) self.camera.light_source.move_to(3*IN) self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) - self.add(axes, sphere) \ No newline at end of file + self.add(axes, sphere) + +.. manim:: Example3DNo3 + :quality: medium + + class Example3DNo3(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + circle=Circle() + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(circle,axes) + self.begin_ambient_camera_rotation(rate=0.1) + self.wait(3) + self.stop_ambient_camera_rotation() + self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES) + self.wait() + +.. manim:: Example3DNo4 + :quality: medium + + class Example3DNo4(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + circle=Circle() + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(circle,axes) + self.begin_3dillusion_camera_rotation(rate=2) + self.wait(PI) + self.stop_3dillusion_camera_rotation() + +.. manim:: ParametricCurve1 + :quality: medium + + class ParametricCurve1(ThreeDScene): + def construct(self): + curve1 = ParametricFunction( + lambda u: np.array([ + 1.2 * np.cos(u), + 1.2 * np.sin(u), + u * 0.05 + ]), color=RED, t_min=-3 * TAU, t_max=5 * TAU, + ).set_shade_in_3d(True) + axes = ThreeDAxes() + self.add(axes, curve1) + self.set_camera_orientation(phi=80 * DEGREES, theta=-60 * DEGREES) From 2e32d9656553b386272d7e181d24ec9433652ecd Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 11:42:57 +0200 Subject: [PATCH 12/34] # added one advanced project --- docs/source/examples/advanced_projects.rst | 89 +++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/docs/source/examples/advanced_projects.rst b/docs/source/examples/advanced_projects.rst index 1e59381970..d3934d2bea 100644 --- a/docs/source/examples/advanced_projects.rst +++ b/docs/source/examples/advanced_projects.rst @@ -1,4 +1,91 @@ Advanced Projects ================================= -This page is currently under construction. It will feature a selection of advanced projects built with manim. +.. manim:: ExampleSineCurve + :quality: medium + + class ExampleSineCurve(Scene): + def construct(self): + self.show_axis() + self.show_circle() + self.move_dot_and_draw_curve() + self.wait() + + def show_axis(self): + x_start = np.array([-6,0,0]) + x_end = np.array([6,0,0]) + + y_start = np.array([-4,-2,0]) + y_end = np.array([-4,2,0]) + + x_axis = Line(x_start, x_end) + y_axis = Line(y_start, y_end) + + self.add(x_axis, y_axis) + self.add_x_labels() + + self.orgin_point = np.array([-4,0,0]) + self.curve_start = np.array([-3,0,0]) + + def add_x_labels(self): + x_labels = [ + TexMobject("\pi"), TexMobject("2 \pi"), + TexMobject("3 \pi"), TexMobject("4 \pi"), + ] + + for i in range(len(x_labels)): + x_labels[i].next_to(np.array([-1+2*i,0,0]), DOWN ) + self.add(x_labels[i]) + + def show_circle(self): + circle = Circle(radius=1) + circle.move_to(self.orgin_point) + + self.add(circle) + self.circle = circle + + def move_dot_and_draw_curve(self): + orbit = self.circle + orgin_point = self.orgin_point + + dot = Dot(radius=0.08, color=YELLOW) + dot.move_to(orbit.point_from_proportion(0)) + self.t_offset = 0 + rate = 0.25 + + def go_around_circle(mob, dt): + self.t_offset += (dt * rate) + # print(self.t_offset) + mob.move_to(orbit.point_from_proportion(self.t_offset % 1)) + + def get_line_to_circle(): + return Line(orgin_point, dot.get_center(), color=BLUE) + + def get_line_to_curve(): + x = self.curve_start[0] + self.t_offset * 4 + y = dot.get_center()[1] + return Line(dot.get_center(), np.array([x,y,0]), color=YELLOW_A, stroke_width=2 ) + + + self.curve = VGroup() + self.curve.add(Line(self.curve_start,self.curve_start)) + def get_curve(): + last_line = self.curve[-1] + x = self.curve_start[0] + self.t_offset * 4 + y = dot.get_center()[1] + new_line = Line(last_line.get_end(),np.array([x,y,0]), color=YELLOW_D) + self.curve.add(new_line) + + return self.curve + + dot.add_updater(go_around_circle) + + origin_to_circle_line = always_redraw(get_line_to_circle) + dot_to_curve_line = always_redraw(get_line_to_curve) + sine_curve_line = always_redraw(get_curve) + + self.add(dot) + self.add(orbit, origin_to_circle_line, dot_to_curve_line, sine_curve_line) + self.wait(8.5) + + dot.remove_updater(go_around_circle) From 58b4233656c6fb9f47cf6531c4e8709d2dd627d4 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 11:46:11 +0200 Subject: [PATCH 13/34] fixed error --- docs/source/examples/3d.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index f0f77d8fb7..69771797e4 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -66,10 +66,11 @@ self.wait(PI) self.stop_3dillusion_camera_rotation() -.. manim:: ParametricCurve1 +.. manim:: Example3DNo5 :quality: medium + :save_last_frame: - class ParametricCurve1(ThreeDScene): + class Example3DNo5(ThreeDScene): def construct(self): curve1 = ParametricFunction( lambda u: np.array([ @@ -81,3 +82,5 @@ axes = ThreeDAxes() self.add(axes, curve1) self.set_camera_orientation(phi=80 * DEGREES, theta=-60 * DEGREES) + self.wait() + From ee0c1c3b19d77bd2621b6ca760391b25af7e64d4 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 12:06:53 +0200 Subject: [PATCH 14/34] small changes --- docs/source/examples/3d.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index 69771797e4..1ee313617e 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -19,6 +19,8 @@ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, sphere) + + .. manim:: Example3DNo2 :quality: medium :save_last_frame: @@ -38,6 +40,8 @@ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, sphere) +and one more example: + .. manim:: Example3DNo3 :quality: medium @@ -53,6 +57,8 @@ self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES) self.wait() +and further: + .. manim:: Example3DNo4 :quality: medium From 3e8145e22f1935fd99ff117ce31472e9ba3fdde7 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 12:20:22 +0200 Subject: [PATCH 15/34] 3d render --- docs/source/examples/3d.rst | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index 1ee313617e..c65a36fd4c 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -1,6 +1,8 @@ 3D Scenes ================================= +Hello World + .. manim:: Example3DNo1 :quality: medium :save_last_frame: @@ -19,7 +21,20 @@ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, sphere) +.. manim:: Example3DNo3 + :quality: medium + class Example3DNo3(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + circle=Circle() + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(circle,axes) + self.begin_ambient_camera_rotation(rate=0.1) + self.wait(3) + self.stop_ambient_camera_rotation() + self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES) + self.wait() .. manim:: Example3DNo2 :quality: medium @@ -42,20 +57,7 @@ and one more example: -.. manim:: Example3DNo3 - :quality: medium - class Example3DNo3(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - circle=Circle() - self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) - self.add(circle,axes) - self.begin_ambient_camera_rotation(rate=0.1) - self.wait(3) - self.stop_ambient_camera_rotation() - self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES) - self.wait() and further: From 0ce2ba179b8a36bb48a113c7f4e9feba271c2185 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 12:33:55 +0200 Subject: [PATCH 16/34] another idea with the file 3d_fix.rst --- docs/source/examples.rst | 1 + docs/source/examples/3d_fix.rst | 94 +++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 docs/source/examples/3d_fix.rst diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 7aa8dc1d30..4c38c41e77 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -9,6 +9,7 @@ Examples examples/text examples/formulas examples/3d + examples/3d_fix examples/camera_settings examples/animations examples/neat_projects diff --git a/docs/source/examples/3d_fix.rst b/docs/source/examples/3d_fix.rst new file mode 100644 index 0000000000..c65a36fd4c --- /dev/null +++ b/docs/source/examples/3d_fix.rst @@ -0,0 +1,94 @@ +3D Scenes +================================= + +Hello World + +.. manim:: Example3DNo1 + :quality: medium + :save_last_frame: + + class Example3DNo1(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + sphere = ParametricSurface( + lambda u, v: np.array([ + 1.5 * np.cos(u) * np.cos(v), + 1.5 * np.cos(u) * np.sin(v), + 1.5 * np.sin(u) + ]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2, + checkerboard_colors=[RED_D, RED_E], resolution=(15, 32) + ) + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(axes, sphere) + +.. manim:: Example3DNo3 + :quality: medium + + class Example3DNo3(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + circle=Circle() + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(circle,axes) + self.begin_ambient_camera_rotation(rate=0.1) + self.wait(3) + self.stop_ambient_camera_rotation() + self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES) + self.wait() + +.. manim:: Example3DNo2 + :quality: medium + :save_last_frame: + + class Example3DNo2(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + sphere = ParametricSurface( + lambda u, v: np.array([ + 1.5 * np.cos(u) * np.cos(v), + 1.5 * np.cos(u) * np.sin(v), + 1.5 * np.sin(u) + ]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2, + checkerboard_colors=[RED_D, RED_E], resolution=(15, 32) + ) + self.camera.light_source.move_to(3*IN) + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(axes, sphere) + +and one more example: + + + +and further: + +.. manim:: Example3DNo4 + :quality: medium + + class Example3DNo4(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + circle=Circle() + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(circle,axes) + self.begin_3dillusion_camera_rotation(rate=2) + self.wait(PI) + self.stop_3dillusion_camera_rotation() + +.. manim:: Example3DNo5 + :quality: medium + :save_last_frame: + + class Example3DNo5(ThreeDScene): + def construct(self): + curve1 = ParametricFunction( + lambda u: np.array([ + 1.2 * np.cos(u), + 1.2 * np.sin(u), + u * 0.05 + ]), color=RED, t_min=-3 * TAU, t_max=5 * TAU, + ).set_shade_in_3d(True) + axes = ThreeDAxes() + self.add(axes, curve1) + self.set_camera_orientation(phi=80 * DEGREES, theta=-60 * DEGREES) + self.wait() + From 38fa13d13d95c900874b7a8167c4c296bfacc22e Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 13:32:27 +0200 Subject: [PATCH 17/34] # one more change --- docs/source/examples/3d.rst | 34 +++++------- docs/source/examples/3d_fix.rst | 94 --------------------------------- 2 files changed, 13 insertions(+), 115 deletions(-) delete mode 100644 docs/source/examples/3d_fix.rst diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index c65a36fd4c..69771797e4 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -1,8 +1,6 @@ 3D Scenes ================================= -Hello World - .. manim:: Example3DNo1 :quality: medium :save_last_frame: @@ -21,21 +19,6 @@ Hello World self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, sphere) -.. manim:: Example3DNo3 - :quality: medium - - class Example3DNo3(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - circle=Circle() - self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) - self.add(circle,axes) - self.begin_ambient_camera_rotation(rate=0.1) - self.wait(3) - self.stop_ambient_camera_rotation() - self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES) - self.wait() - .. manim:: Example3DNo2 :quality: medium :save_last_frame: @@ -55,11 +38,20 @@ Hello World self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, sphere) -and one more example: - - +.. manim:: Example3DNo3 + :quality: medium -and further: + class Example3DNo3(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + circle=Circle() + self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) + self.add(circle,axes) + self.begin_ambient_camera_rotation(rate=0.1) + self.wait(3) + self.stop_ambient_camera_rotation() + self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES) + self.wait() .. manim:: Example3DNo4 :quality: medium diff --git a/docs/source/examples/3d_fix.rst b/docs/source/examples/3d_fix.rst deleted file mode 100644 index c65a36fd4c..0000000000 --- a/docs/source/examples/3d_fix.rst +++ /dev/null @@ -1,94 +0,0 @@ -3D Scenes -================================= - -Hello World - -.. manim:: Example3DNo1 - :quality: medium - :save_last_frame: - - class Example3DNo1(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - sphere = ParametricSurface( - lambda u, v: np.array([ - 1.5 * np.cos(u) * np.cos(v), - 1.5 * np.cos(u) * np.sin(v), - 1.5 * np.sin(u) - ]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2, - checkerboard_colors=[RED_D, RED_E], resolution=(15, 32) - ) - self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) - self.add(axes, sphere) - -.. manim:: Example3DNo3 - :quality: medium - - class Example3DNo3(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - circle=Circle() - self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) - self.add(circle,axes) - self.begin_ambient_camera_rotation(rate=0.1) - self.wait(3) - self.stop_ambient_camera_rotation() - self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES) - self.wait() - -.. manim:: Example3DNo2 - :quality: medium - :save_last_frame: - - class Example3DNo2(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - sphere = ParametricSurface( - lambda u, v: np.array([ - 1.5 * np.cos(u) * np.cos(v), - 1.5 * np.cos(u) * np.sin(v), - 1.5 * np.sin(u) - ]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2, - checkerboard_colors=[RED_D, RED_E], resolution=(15, 32) - ) - self.camera.light_source.move_to(3*IN) - self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) - self.add(axes, sphere) - -and one more example: - - - -and further: - -.. manim:: Example3DNo4 - :quality: medium - - class Example3DNo4(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - circle=Circle() - self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) - self.add(circle,axes) - self.begin_3dillusion_camera_rotation(rate=2) - self.wait(PI) - self.stop_3dillusion_camera_rotation() - -.. manim:: Example3DNo5 - :quality: medium - :save_last_frame: - - class Example3DNo5(ThreeDScene): - def construct(self): - curve1 = ParametricFunction( - lambda u: np.array([ - 1.2 * np.cos(u), - 1.2 * np.sin(u), - u * 0.05 - ]), color=RED, t_min=-3 * TAU, t_max=5 * TAU, - ).set_shade_in_3d(True) - axes = ThreeDAxes() - self.add(axes, curve1) - self.set_camera_orientation(phi=80 * DEGREES, theta=-60 * DEGREES) - self.wait() - From 2978804bdf0f167bf93c7f97371b56e9079e2260 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 13:41:16 +0200 Subject: [PATCH 18/34] some more formula examples --- docs/source/examples/formulas.rst | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/docs/source/examples/formulas.rst b/docs/source/examples/formulas.rst index be99a83fd9..740c9ce66e 100644 --- a/docs/source/examples/formulas.rst +++ b/docs/source/examples/formulas.rst @@ -10,3 +10,52 @@ Formulas t = MathTex(r"\int_a^b f'(x) dx = f(b)- f(a)") self.add(t) self.wait(1) + + +.. manim:: MoveFrameBox + :quality: medium + + class MoveFrameBox(Scene): + def construct(self): + text=TexMobject( + "\\frac{d}{dx}f(x)g(x)=","f(x)\\frac{d}{dx}g(x)","+", + "g(x)\\frac{d}{dx}f(x)" + ) + self.play(Write(text)) + framebox1 = SurroundingRectangle(text[1], buff = .1) + framebox2 = SurroundingRectangle(text[3], buff = .1) + self.play( + ShowCreation(framebox1), + ) + self.wait() + self.play( + ReplacementTransform(framebox1,framebox2), + ) + self.wait() + +.. manim:: MoveBraces + :quality: medium + + class MoveBraces(Scene): + def construct(self): + text=TexMobject( + "\\frac{d}{dx}f(x)g(x)=", #0 + "f(x)\\frac{d}{dx}g(x)", #1 + "+", #2 + "g(x)\\frac{d}{dx}f(x)" #3 + ) + self.play(Write(text)) + brace1 = Brace(text[1], UP, buff = SMALL_BUFF) + brace2 = Brace(text[3], UP, buff = SMALL_BUFF) + t1 = brace1.get_text("$g'f$") + t2 = brace2.get_text("$f'g$") + self.play( + GrowFromCenter(brace1), + FadeIn(t1), + ) + self.wait() + self.play( + ReplacementTransform(brace1,brace2), + ReplacementTransform(t1,t2) + ) + self.wait() From 9305baf54e57bcd7b4791e30846baeb4b8fa6c79 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Thu, 24 Sep 2020 13:55:07 +0200 Subject: [PATCH 19/34] fix indent --- docs/source/examples/formulas.rst | 42 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/source/examples/formulas.rst b/docs/source/examples/formulas.rst index 740c9ce66e..ffccf9cbfd 100644 --- a/docs/source/examples/formulas.rst +++ b/docs/source/examples/formulas.rst @@ -37,25 +37,25 @@ Formulas :quality: medium class MoveBraces(Scene): - def construct(self): - text=TexMobject( - "\\frac{d}{dx}f(x)g(x)=", #0 - "f(x)\\frac{d}{dx}g(x)", #1 - "+", #2 - "g(x)\\frac{d}{dx}f(x)" #3 - ) - self.play(Write(text)) - brace1 = Brace(text[1], UP, buff = SMALL_BUFF) - brace2 = Brace(text[3], UP, buff = SMALL_BUFF) - t1 = brace1.get_text("$g'f$") - t2 = brace2.get_text("$f'g$") - self.play( - GrowFromCenter(brace1), - FadeIn(t1), + def construct(self): + text=TexMobject( + "\\frac{d}{dx}f(x)g(x)=", #0 + "f(x)\\frac{d}{dx}g(x)", #1 + "+", #2 + "g(x)\\frac{d}{dx}f(x)" #3 ) - self.wait() - self.play( - ReplacementTransform(brace1,brace2), - ReplacementTransform(t1,t2) - ) - self.wait() + self.play(Write(text)) + brace1 = Brace(text[1], UP, buff = SMALL_BUFF) + brace2 = Brace(text[3], UP, buff = SMALL_BUFF) + t1 = brace1.get_text("$g'f$") + t2 = brace2.get_text("$f'g$") + self.play( + GrowFromCenter(brace1), + FadeIn(t1), + ) + self.wait() + self.play( + ReplacementTransform(brace1,brace2), + ReplacementTransform(t1,t2) + ) + self.wait() From f5aa9a0f839ac17a3477e5a58e9ad5a82b2ded40 Mon Sep 17 00:00:00 2001 From: Benjamin Hackl Date: Sun, 27 Sep 2020 23:42:10 +0200 Subject: [PATCH 20/34] remove reference to examples/3d_fix --- docs/source/examples.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 4c38c41e77..7aa8dc1d30 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -9,7 +9,6 @@ Examples examples/text examples/formulas examples/3d - examples/3d_fix examples/camera_settings examples/animations examples/neat_projects From 0673f1d873bdc01b7b192ab6068bf2a5332c5ee7 Mon Sep 17 00:00:00 2001 From: Benjamin Hackl Date: Sun, 27 Sep 2020 23:44:47 +0200 Subject: [PATCH 21/34] change default resolution for videos in doc to 480p30 --- docs/source/examples/3d.rst | 5 ----- docs/source/examples/advanced_projects.rst | 1 - docs/source/examples/animations.rst | 6 ------ docs/source/examples/annotations.rst | 1 - docs/source/examples/camera_settings.rst | 10 ---------- docs/source/examples/formulas.rst | 3 --- docs/source/examples/plots.rst | 9 --------- docs/source/examples/shapes.rst | 3 --- docs/source/examples/text.rst | 13 ------------- docs/source/manim_directive.py | 6 +++--- docs/source/tutorials/building_blocks.rst | 8 -------- docs/source/tutorials/quickstart.rst | 2 -- manim/mobject/changing.py | 2 -- manim/mobject/geometry.py | 1 - manim/mobject/value_tracker.py | 1 - 15 files changed, 3 insertions(+), 68 deletions(-) diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index 69771797e4..f43de3057d 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -2,7 +2,6 @@ ================================= .. manim:: Example3DNo1 - :quality: medium :save_last_frame: class Example3DNo1(ThreeDScene): @@ -20,7 +19,6 @@ self.add(axes, sphere) .. manim:: Example3DNo2 - :quality: medium :save_last_frame: class Example3DNo2(ThreeDScene): @@ -39,7 +37,6 @@ self.add(axes, sphere) .. manim:: Example3DNo3 - :quality: medium class Example3DNo3(ThreeDScene): def construct(self): @@ -54,7 +51,6 @@ self.wait() .. manim:: Example3DNo4 - :quality: medium class Example3DNo4(ThreeDScene): def construct(self): @@ -67,7 +63,6 @@ self.stop_3dillusion_camera_rotation() .. manim:: Example3DNo5 - :quality: medium :save_last_frame: class Example3DNo5(ThreeDScene): diff --git a/docs/source/examples/advanced_projects.rst b/docs/source/examples/advanced_projects.rst index d3934d2bea..51d4cbce9d 100644 --- a/docs/source/examples/advanced_projects.rst +++ b/docs/source/examples/advanced_projects.rst @@ -2,7 +2,6 @@ Advanced Projects ================================= .. manim:: ExampleSineCurve - :quality: medium class ExampleSineCurve(Scene): def construct(self): diff --git a/docs/source/examples/animations.rst b/docs/source/examples/animations.rst index 40f7c91615..33eab8e9ca 100644 --- a/docs/source/examples/animations.rst +++ b/docs/source/examples/animations.rst @@ -11,7 +11,6 @@ Updaters ########## .. manim:: Updater1Example - :quality: medium class Updater1Example(Scene): def construct(self): @@ -24,7 +23,6 @@ Updaters self.wait(PI) .. manim:: Updater2Example - :quality: medium class Updater2Example(Scene): def construct(self): @@ -44,7 +42,6 @@ Updaters self.wait(0.5) .. manim:: Example3 - :quality: medium class Example3(Scene): def construct(self): @@ -62,7 +59,6 @@ Updaters self.play(pointer_value.set_value, 3) .. manim:: Example4 - :quality: medium class Example4(Scene): def construct(self): @@ -82,7 +78,6 @@ Updaters self.wait() .. manim:: Example1ValTracker - :quality: medium class Example1ValTracker(Scene): def construct(self): @@ -98,7 +93,6 @@ Updaters self.wait() .. manim:: Example2ValTracker - :quality: medium class Example2ValTracker(Scene): def construct(self): diff --git a/docs/source/examples/annotations.rst b/docs/source/examples/annotations.rst index d325eedc24..1d1783386f 100644 --- a/docs/source/examples/annotations.rst +++ b/docs/source/examples/annotations.rst @@ -2,7 +2,6 @@ Annotations ================================= .. manim:: AnnotateBrace - :quality: medium :save_last_frame: class AnnotateBrace(Scene): diff --git a/docs/source/examples/camera_settings.rst b/docs/source/examples/camera_settings.rst index 3193dbc81e..ac8e5dcc34 100644 --- a/docs/source/examples/camera_settings.rst +++ b/docs/source/examples/camera_settings.rst @@ -2,7 +2,6 @@ Camera Settings ================================= .. manim:: Example1 - :quality: medium class Example1(MovingCameraScene): def construct(self): @@ -12,7 +11,6 @@ Camera Settings self.wait() .. manim:: Example2a - :quality: medium class Example2a(MovingCameraScene): def construct(self): @@ -24,7 +22,6 @@ Camera Settings self.play(Restore(self.camera_frame)) .. manim:: Example2b - :quality: medium class Example2b(MovingCameraScene): def construct(self): @@ -36,7 +33,6 @@ Camera Settings .. manim:: Example3 - :quality: medium class Example3(MovingCameraScene): def construct(self): @@ -48,7 +44,6 @@ Camera Settings self.play(self.camera_frame.move_to, t) .. manim:: Example4 - :quality: medium class Example4(MovingCameraScene): def construct(self): @@ -65,7 +60,6 @@ Camera Settings self.camera_frame.set_width,14) .. manim:: Example5 - :quality: medium class Example5(GraphScene, MovingCameraScene): def setup(self): @@ -88,7 +82,6 @@ Camera Settings self.wait() .. manim:: Example6 - :quality: medium class Example6(GraphScene, MovingCameraScene): def setup(self): @@ -123,7 +116,6 @@ Note: ZoomedScene is derived class of MovingCameraScene, so one can use all functionality that were used before in the MovingCameraScene examples. .. manim:: ExampleZoom1 - :quality: medium class ExampleZoom1(ZoomedScene): def construct(self): @@ -135,7 +127,6 @@ so one can use all functionality that were used before in the MovingCameraScene self.play(dot.shift, LEFT) .. manim:: ExampleZoom2 - :quality: medium class ExampleZoom2(ZoomedScene): CONFIG = { @@ -161,7 +152,6 @@ so one can use all functionality that were used before in the MovingCameraScene .. manim:: ExampleZoom3 - :quality: medium class ExampleZoom3(ZoomedScene): CONFIG = { diff --git a/docs/source/examples/formulas.rst b/docs/source/examples/formulas.rst index ffccf9cbfd..05482980b5 100644 --- a/docs/source/examples/formulas.rst +++ b/docs/source/examples/formulas.rst @@ -2,7 +2,6 @@ Formulas ================================= .. manim:: Formula1 - :quality: medium :save_last_frame: class Formula1(Scene): @@ -13,7 +12,6 @@ Formulas .. manim:: MoveFrameBox - :quality: medium class MoveFrameBox(Scene): def construct(self): @@ -34,7 +32,6 @@ Formulas self.wait() .. manim:: MoveBraces - :quality: medium class MoveBraces(Scene): def construct(self): diff --git a/docs/source/examples/plots.rst b/docs/source/examples/plots.rst index 35428a414a..6be9699ae8 100644 --- a/docs/source/examples/plots.rst +++ b/docs/source/examples/plots.rst @@ -5,7 +5,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. .. manim:: Plot1 - :quality: medium :save_last_frame: class Plot1(GraphScene): @@ -15,7 +14,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.add(func_graph) .. manim:: Plot2yLabel - :quality: medium :save_last_frame: class Plot2yLabel(GraphScene): @@ -34,7 +32,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.add(dot) .. manim:: Plot3DataPoints - :quality: medium :save_last_frame: class Plot3DataPoints(GraphScene): @@ -51,7 +48,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.add(dot) .. manim:: Plot3bGaussian - :quality: medium :save_last_frame: amp = 5 @@ -68,7 +64,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.add(graph) .. manim:: Plot3cGaussian - :quality: medium :save_last_frame: class Plot3cGaussian(GraphScene): @@ -84,7 +79,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. .. manim:: Plot4SinCos - :quality: medium :save_last_frame: class Plot4SinCos(GraphScene): @@ -120,7 +114,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.add(func_graph, func_graph2, vert_line, graph_lab, graph_lab2, two_pi) .. manim:: Plot5Area - :quality: medium :save_last_frame: class Plot5Area(GraphScene): @@ -144,7 +137,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.add(curve1, curve2, line1, line2, area1, area2) .. manim:: Plot6HeatDiagram - :quality: medium :save_last_frame: class Plot6HeatDiagram(GraphScene): @@ -178,7 +170,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. The following example illustrates how to draw parametric function plots. .. manim:: ParamFunc1 - :quality: medium :save_last_frame: class ParamFunc1(Scene): diff --git a/docs/source/examples/shapes.rst b/docs/source/examples/shapes.rst index 9ac281f319..918cba95d6 100644 --- a/docs/source/examples/shapes.rst +++ b/docs/source/examples/shapes.rst @@ -2,7 +2,6 @@ Shapes ================================= .. manim:: Example1Shape - :quality: medium :save_last_frame: class Example1Shape(Scene): @@ -18,7 +17,6 @@ Shapes self.wait(1) .. manim:: Example1ImageFromArray - :quality: medium :save_last_frame: class Example1ImageFromArray(Scene): @@ -29,7 +27,6 @@ Shapes self.add(image) .. manim:: Example2ImageFromFile - :quality: medium :save_last_frame: class Example2ImageFromFile(Scene): diff --git a/docs/source/examples/text.rst b/docs/source/examples/text.rst index 20d5322d01..724dea4452 100644 --- a/docs/source/examples/text.rst +++ b/docs/source/examples/text.rst @@ -2,7 +2,6 @@ Text ================================= .. manim:: Example1Text - :quality: medium :save_last_frame: class Example1Text(Scene): @@ -11,7 +10,6 @@ Text self.add(text) .. manim:: Example2Text - :quality: medium :save_last_frame: class Example2Text(Scene): @@ -21,7 +19,6 @@ Text .. manim:: Example3Text - :quality: medium :save_last_frame: class Example3Text(Scene): @@ -31,7 +28,6 @@ Text .. manim:: Example4Text - :quality: medium :save_last_frame: class Example4Text(Scene): @@ -40,7 +36,6 @@ Text self.add(text) .. manim:: Example5Text - :quality: medium :save_last_frame: class Example5Text(Scene): @@ -49,7 +44,6 @@ Text self.add(text) .. manim:: Example5bText - :quality: medium :save_last_frame: class Example5bText(Scene): @@ -58,7 +52,6 @@ Text self.add(text) .. manim:: Example6Text - :quality: medium :save_last_frame: class Example6Text(Scene): @@ -67,7 +60,6 @@ Text self.add(text) .. manim:: Example7Text - :quality: medium :save_last_frame: class Example7Text(Scene): @@ -76,7 +68,6 @@ Text self.add(text) .. manim:: Example8Text - :quality: medium :save_last_frame: class Example8Text(Scene): @@ -85,7 +76,6 @@ Text self.add(text) .. manim:: Example9Text - :quality: medium :save_last_frame: class Example9Text(Scene): @@ -94,7 +84,6 @@ Text self.add(text) .. manim:: Example10Text - :quality: medium :save_last_frame: class Example10Text(Scene): @@ -103,7 +92,6 @@ Text self.add(text) .. manim:: Example11Text - :quality: medium :save_last_frame: class Example11Text(Scene): @@ -112,7 +100,6 @@ Text self.add(text) .. manim:: Example12Text - :quality: medium :save_last_frame: class Example12Text(Scene): diff --git a/docs/source/manim_directive.py b/docs/source/manim_directive.py index cf92b4c0d4..882512b3c3 100644 --- a/docs/source/manim_directive.py +++ b/docs/source/manim_directive.py @@ -106,9 +106,9 @@ def run(self): save_last_frame = "save_last_frame" in self.options assert not (save_as_gif and save_last_frame) - frame_rate = config["frame_rate"] - pixel_height = config["pixel_height"] - pixel_width = config["pixel_width"] + frame_rate = 30 + pixel_height = 480 + pixel_width = 854 if "quality" in self.options: quality = self.options["quality"] diff --git a/docs/source/tutorials/building_blocks.rst b/docs/source/tutorials/building_blocks.rst index 96a4f8a27e..41f4ad5a5d 100644 --- a/docs/source/tutorials/building_blocks.rst +++ b/docs/source/tutorials/building_blocks.rst @@ -61,7 +61,6 @@ screen, simply call the :meth:`~.Scene.remove` method from the containing :class:`.Scene`. .. manim:: CreatingMobjects - :quality: medium class CreatingMobjects(Scene): def construct(self): @@ -80,7 +79,6 @@ some mobjects to it. This script generates a static picture that displays a circle, a square, and a triangle: .. manim:: Shapes - :quality: medium class Shapes(Scene): def construct(self): @@ -112,7 +110,6 @@ There are many other possible ways to place mobjects on the screen, for example ``MobjectPlacement`` uses all three. .. manim:: MobjectPlacement - :quality: medium class MobjectPlacement(Scene): def construct(self): @@ -160,7 +157,6 @@ Styling mobjects The following scene changes the default aesthetics of the mobjects. .. manim:: MobjectStyling - :quality: medium class MobjectStyling(Scene): def construct(self): @@ -196,7 +192,6 @@ The next scene is exactly the same as the ``MobjectStyling`` scene from the previous section, except for exactly one line. .. manim:: MobjectZOrder - :quality: medium class MobjectZOrder(Scene): def construct(self): @@ -229,7 +224,6 @@ At the heart of manim is animation. Generally, you can add an animation to your scene by calling the :meth:`~.Scene.play` method. .. manim:: SomeAnimations - :quality: medium class SomeAnimations(Scene): def construct(self): @@ -265,7 +259,6 @@ method that changes a mobject's property can be used as an animation, through the use of :class:`.ApplyMethod`. .. manim:: ApplyMethodExample - :quality: medium class ApplyMethodExample(Scene): def construct(self): @@ -293,7 +286,6 @@ By default, any animation passed to :meth:`play` lasts for exactly one second. Use the :code:`run_time` argument to control the duration. .. manim:: RunTime - :quality: medium class RunTime(Scene): def construct(self): diff --git a/docs/source/tutorials/quickstart.rst b/docs/source/tutorials/quickstart.rst index 5f16145977..79a8341000 100644 --- a/docs/source/tutorials/quickstart.rst +++ b/docs/source/tutorials/quickstart.rst @@ -59,7 +59,6 @@ video playing the following animation. .. manim:: SquareToCircle :hide_source: - :quality: low class SquareToCircle(Scene): def construct(self): @@ -155,7 +154,6 @@ The output should look as follows. .. manim:: SquareToCircle2 :hide_source: - :quality: low class SquareToCircle2(Scene): def construct(self): diff --git a/manim/mobject/changing.py b/manim/mobject/changing.py index db73ac5660..ab0fab971d 100644 --- a/manim/mobject/changing.py +++ b/manim/mobject/changing.py @@ -16,7 +16,6 @@ class AnimatedBoundary(VGroup): Examples -------- .. manim:: AnimatedBoundaryExample - :quality: low class AnimatedBoundaryExample(Scene): def construct(self): @@ -89,7 +88,6 @@ class TracedPath(VMobject): Examples -------- .. manim:: TracedPathExample - :quality: low class TracedPathExample(Scene): def construct(self): diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py index 74ab65e9ed..6f332c0721 100644 --- a/manim/mobject/geometry.py +++ b/manim/mobject/geometry.py @@ -897,7 +897,6 @@ class ArrowTip(VMobject): a custom one like this: .. manim:: CustomTipExample - :quality: low >>> class MyCustomArrowTip(ArrowTip, RegularPolygon): ... def __init__(self, **kwargs): diff --git a/manim/mobject/value_tracker.py b/manim/mobject/value_tracker.py index aeeac1478b..13ae1d7586 100644 --- a/manim/mobject/value_tracker.py +++ b/manim/mobject/value_tracker.py @@ -21,7 +21,6 @@ class ValueTracker(Mobject): Examples -------- .. manim:: ValueTrackerExample - :quality: low class ValueTrackerExample(Scene): def construct(self): From 40ae5d7bd4e888a1cd0ded938183e254e69e4c85 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Mon, 28 Sep 2020 20:37:53 +0200 Subject: [PATCH 22/34] Apply suggestions leotrs Co-authored-by: Leo Torres --- docs/source/examples/advanced_projects.rst | 2 +- docs/source/examples/formulas.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/examples/advanced_projects.rst b/docs/source/examples/advanced_projects.rst index 51d4cbce9d..1b4054abc2 100644 --- a/docs/source/examples/advanced_projects.rst +++ b/docs/source/examples/advanced_projects.rst @@ -33,7 +33,7 @@ Advanced Projects ] for i in range(len(x_labels)): - x_labels[i].next_to(np.array([-1+2*i,0,0]), DOWN ) + x_labels[i].next_to(np.array([-1 + 2*i, 0, 0]), DOWN) self.add(x_labels[i]) def show_circle(self): diff --git a/docs/source/examples/formulas.rst b/docs/source/examples/formulas.rst index 05482980b5..c28eefca0d 100644 --- a/docs/source/examples/formulas.rst +++ b/docs/source/examples/formulas.rst @@ -42,8 +42,8 @@ Formulas "g(x)\\frac{d}{dx}f(x)" #3 ) self.play(Write(text)) - brace1 = Brace(text[1], UP, buff = SMALL_BUFF) - brace2 = Brace(text[3], UP, buff = SMALL_BUFF) + brace1 = Brace(text[1], UP, buff=SMALL_BUFF) + brace2 = Brace(text[3], UP, buff=SMALL_BUFF) t1 = brace1.get_text("$g'f$") t2 = brace2.get_text("$f'g$") self.play( From 7ad3136de2d124bc1aa85fc28bf0ce94b6457d8c Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 28 Sep 2020 21:02:57 +0200 Subject: [PATCH 23/34] Added credits and 3d scene changes --- docs/source/examples.rst | 2 ++ docs/source/examples/3d.rst | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 7aa8dc1d30..99d1818112 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -1,6 +1,8 @@ Examples ============ +Special thanks to @theoremofbeethoven ,heejin_park, leotrs and behackl for collecting these examples. + .. toctree:: examples/shapes diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index f43de3057d..b6546d294a 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -18,7 +18,7 @@ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, sphere) -.. manim:: Example3DNo2 +.. manim:: Example3DLightSourcePosition :save_last_frame: class Example3DNo2(ThreeDScene): @@ -32,7 +32,7 @@ ]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2, checkerboard_colors=[RED_D, RED_E], resolution=(15, 32) ) - self.camera.light_source.move_to(3*IN) + self.camera.light_source.move_to(3*IN) # changes the source of the light self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, sphere) From 0ef84277039c182fe4cfecbf9087818123d4304c Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 28 Sep 2020 21:10:17 +0200 Subject: [PATCH 24/34] # removed unnecessary lines --- docs/source/examples/plots.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/examples/plots.rst b/docs/source/examples/plots.rst index 6be9699ae8..d87bf75c16 100644 --- a/docs/source/examples/plots.rst +++ b/docs/source/examples/plots.rst @@ -25,7 +25,7 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. } def construct(self): - self.setup_axes(animate=True) + self.setup_axes() dot = Dot().move_to(self.coords_to_point(PI / 2, 20)) func_graph = self.get_graph(lambda x: 20 * np.sin(x)) self.add(func_graph) @@ -42,7 +42,7 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. def construct(self): data = [1, 2, 2, 4, 4, 1, 3] - self.setup_axes(animate=True) + self.setup_axes() for time, dat in enumerate(data): dot = Dot().move_to(self.coords_to_point(time, dat)) self.add(dot) @@ -127,7 +127,7 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. "x_labeled_nums" : [0,2,3] } def construct(self): - self.setup_axes(animate=False) + self.setup_axes() curve1 = self.get_graph(lambda x : 4*x-x**2, x_min=0,x_max=4) curve2 = self.get_graph(lambda x : 0.8*x**2-3*x+4, x_min=0,x_max=4) line1 = self.get_vertical_line_to_graph(2, curve1, DashedLine, color=YELLOW) @@ -155,7 +155,7 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. def construct(self): data = [20, 0, 0, -5] x = [0, 8, 38, 39] - self.setup_axes(animate=True) + self.setup_axes() dot_collection = VGroup() for time, val in enumerate(data): dot = Dot().move_to(self.coords_to_point(x[time], val)) From db8cd79c946d35451a86fd81190a2a3ca8e65977 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 28 Sep 2020 21:30:50 +0200 Subject: [PATCH 25/34] # implemented lots of changes suggested be leotrs --- docs/source/examples/plots.rst | 42 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/docs/source/examples/plots.rst b/docs/source/examples/plots.rst index d87bf75c16..88cc4ce234 100644 --- a/docs/source/examples/plots.rst +++ b/docs/source/examples/plots.rst @@ -13,7 +13,7 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. func_graph=self.get_graph(lambda x: np.sin(x)) self.add(func_graph) -.. manim:: Plot2yLabel +.. manim:: Plot2yLabelNumbers :save_last_frame: class Plot2yLabel(GraphScene): @@ -28,15 +28,14 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.setup_axes() dot = Dot().move_to(self.coords_to_point(PI / 2, 20)) func_graph = self.get_graph(lambda x: 20 * np.sin(x)) - self.add(func_graph) - self.add(dot) + self.add(dot,func_graph) .. manim:: Plot3DataPoints :save_last_frame: class Plot3DataPoints(GraphScene): CONFIG = { - "y_axis_label": r"Concentration[\%]", + "y_axis_label": r"Concentration [\%]", "x_axis_label": "Time [s]", } @@ -74,7 +73,8 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. sig = 1 return amp * np.exp((-1 / 2 * ((x - mu) / sig) ** 2)) self.setup_axes() - graph = self.get_graph(gaussian, x_min=-1, x_max=10).set_style(stroke_width=5, stroke_color=GREEN) + graph = self.get_graph(gaussian, x_min=-1, x_max=10) + graph.set_style(stroke_width=5, stroke_color=GREEN) self.add(graph) @@ -96,18 +96,12 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. def construct(self): self.setup_axes(animate=False) - - def func_cos(x): - return np.cos(x) - - def func_sin(x): - return np.sin(x) - - func_graph = self.get_graph(func_cos, self.function_color) - func_graph2 = self.get_graph(func_sin) + func_graph = self.get_graph(np.cos, self.function_color) + func_graph2 = self.get_graph(np.sin) vert_line = self.get_vertical_line_to_graph(TAU, func_graph, color=YELLOW) graph_lab = self.get_graph_label(func_graph, label="\\cos(x)") - graph_lab2 = self.get_graph_label(func_graph2, label="\\sin(x)", x_val=-10, direction=UP / 2) + graph_lab2 = self.get_graph_label(func_graph2, label="\\sin(x)", + x_val=-10, direction=UP / 2) two_pi = MathTex(r"x = 2 \pi") label_coord = self.input_to_graph_point(TAU, func_graph) two_pi.next_to(label_coord, RIGHT + UP) @@ -128,8 +122,8 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. } def construct(self): self.setup_axes() - curve1 = self.get_graph(lambda x : 4*x-x**2, x_min=0,x_max=4) - curve2 = self.get_graph(lambda x : 0.8*x**2-3*x+4, x_min=0,x_max=4) + curve1 = self.get_graph(lambda x: 4 * x - x ** 2, x_min=0, x_max=4) + curve2 = self.get_graph(lambda x: 0.8 * x ** 2 - 3 * x + 4, x_min=0, x_max=4) line1 = self.get_vertical_line_to_graph(2, curve1, DashedLine, color=YELLOW) line2 = self.get_vertical_line_to_graph(3, curve1, DashedLine, color=YELLOW) area1 = self.get_area(curve1, 0.3, 0.6, dx_scaling=10, area_color=BLUE) @@ -149,7 +143,6 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. "x_max": 40, "y_labeled_nums": np.arange(-5, 34, 5), "x_labeled_nums": np.arange(0, 40, 5), - } def construct(self): @@ -167,14 +160,15 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.add(l1, l2, l3) -The following example illustrates how to draw parametric function plots. +The following example illustrates how to draw parametric function plots, which does not use `GraphScene` .. manim:: ParamFunc1 :save_last_frame: class ParamFunc1(Scene): - def func(self,t): - return np.array((np.sin(2*t), np.sin(3*t),0)) - def construct(self): - func=ParametricFunction(self.func, t_max=TAU, fill_opacity=0).set_color(RED) - self.add(func.scale(3)) + def func(self, t): + return np.array((np.sin(2 * t), np.sin(3 * t), 0)) + + def construct(self): + func = ParametricFunction(self.func, t_max = TAU, fill_opacity=0).set_color(RED) + self.add(func.scale(3)) \ No newline at end of file From 69737f8c229358cd084f606111c42bdeeefc7f7d Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 28 Sep 2020 21:31:53 +0200 Subject: [PATCH 26/34] # updated credits --- docs/source/examples.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 99d1818112..2e77a82ddd 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -1,7 +1,7 @@ Examples ============ -Special thanks to @theoremofbeethoven ,heejin_park, leotrs and behackl for collecting these examples. +Special thanks to @theoremofbeethoven ,heejin_park, leotrs and behackl and the manim community devs for collecting these examples. .. toctree:: From 6f1f19f2921a83fc0a98259f393d31c9e010f4b3 Mon Sep 17 00:00:00 2001 From: kolibril13 Date: Mon, 28 Sep 2020 21:36:03 +0200 Subject: [PATCH 27/34] # updated scene names --- docs/source/examples/3d.rst | 2 +- docs/source/examples/plots.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index b6546d294a..6a46f018df 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -21,7 +21,7 @@ .. manim:: Example3DLightSourcePosition :save_last_frame: - class Example3DNo2(ThreeDScene): + class Example3DLightSourcePosition(ThreeDScene): def construct(self): axes = ThreeDAxes() sphere = ParametricSurface( diff --git a/docs/source/examples/plots.rst b/docs/source/examples/plots.rst index 88cc4ce234..10b120869c 100644 --- a/docs/source/examples/plots.rst +++ b/docs/source/examples/plots.rst @@ -16,7 +16,7 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. .. manim:: Plot2yLabelNumbers :save_last_frame: - class Plot2yLabel(GraphScene): + class Plot2yLabelNumbers(GraphScene): CONFIG = { "y_min": 0, "y_max": 100, From 834aba53995e6698f2b1dec0ee6ff372f9b4774c Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Mon, 28 Sep 2020 21:38:17 +0200 Subject: [PATCH 28/34] Update docs/source/examples/shapes.rst Co-authored-by: Leo Torres --- docs/source/examples/shapes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/examples/shapes.rst b/docs/source/examples/shapes.rst index 918cba95d6..2c362cd883 100644 --- a/docs/source/examples/shapes.rst +++ b/docs/source/examples/shapes.rst @@ -31,7 +31,7 @@ Shapes class Example2ImageFromFile(Scene): def construct(self): - # these four lines, when you want to import an image from the web + # Use PIL when you want to import an image from the web import requests from PIL import Image img = Image.open(requests.get("https://raw.githubusercontent.com/ManimCommunity/manim/master/logo/cropped.png", @@ -40,4 +40,4 @@ Shapes # this line, when you want to import your Image on your machine # img_mobject = ImageMobject("") img_mobject.scale(3) - self.add(img_mobject) \ No newline at end of file + self.add(img_mobject) From 53ec42d2ff56dd9d15b4ca5be21d7653e6a7710a Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Mon, 28 Sep 2020 22:42:19 +0200 Subject: [PATCH 29/34] updated credits --- docs/source/examples/advanced_projects.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/examples/advanced_projects.rst b/docs/source/examples/advanced_projects.rst index 1b4054abc2..4626cf74dc 100644 --- a/docs/source/examples/advanced_projects.rst +++ b/docs/source/examples/advanced_projects.rst @@ -4,6 +4,7 @@ Advanced Projects .. manim:: ExampleSineCurve class ExampleSineCurve(Scene): + # contributed by heejin_park, https://infograph.tistory.com/230 def construct(self): self.show_axis() self.show_circle() From 03e831228f22b87274951e407448490ecadb0990 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Mon, 28 Sep 2020 23:10:20 +0200 Subject: [PATCH 30/34] updated examples entery --- docs/source/examples.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 2e77a82ddd..fea2e23c56 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -1,8 +1,6 @@ Examples ============ -Special thanks to @theoremofbeethoven ,heejin_park, leotrs and behackl and the manim community devs for collecting these examples. - .. toctree:: examples/shapes @@ -14,4 +12,4 @@ Special thanks to @theoremofbeethoven ,heejin_park, leotrs and behackl and the m examples/camera_settings examples/animations examples/neat_projects - examples/advanced_projects \ No newline at end of file + examples/advanced_projects From 1aad7e67cf661100ad5d84e2991d9457871280d9 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Mon, 28 Sep 2020 23:12:24 +0200 Subject: [PATCH 31/34] Update camera_settings.rst --- docs/source/examples/camera_settings.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/examples/camera_settings.rst b/docs/source/examples/camera_settings.rst index ac8e5dcc34..78abf71f93 100644 --- a/docs/source/examples/camera_settings.rst +++ b/docs/source/examples/camera_settings.rst @@ -152,7 +152,7 @@ so one can use all functionality that were used before in the MovingCameraScene .. manim:: ExampleZoom3 - + # contributed by TheoremofBeethoven, www.youtube.com/c/TheoremofBeethoven class ExampleZoom3(ZoomedScene): CONFIG = { "zoom_factor": 0.3, @@ -211,4 +211,4 @@ so one can use all functionality that were used before in the MovingCameraScene self.wait() self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera, rate_func=lambda t: smooth(1 - t)) self.play(Uncreate(zoomed_display_frame), FadeOut(frame)) - self.wait() \ No newline at end of file + self.wait() From 01f07d21d350635c40ddfbfb45a1bdbaff5e7ddf Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Mon, 28 Sep 2020 23:22:56 +0200 Subject: [PATCH 32/34] changed two lines --- docs/source/examples/camera_settings.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/examples/camera_settings.rst b/docs/source/examples/camera_settings.rst index 78abf71f93..5b28addf02 100644 --- a/docs/source/examples/camera_settings.rst +++ b/docs/source/examples/camera_settings.rst @@ -152,8 +152,9 @@ so one can use all functionality that were used before in the MovingCameraScene .. manim:: ExampleZoom3 - # contributed by TheoremofBeethoven, www.youtube.com/c/TheoremofBeethoven + class ExampleZoom3(ZoomedScene): + # contributed by TheoremofBeethoven, www.youtube.com/c/TheoremofBeethoven CONFIG = { "zoom_factor": 0.3, "zoomed_display_height": 1, From 093be8e5dcd27bb958325714aee9decf7c8f3a50 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Fri, 2 Oct 2020 15:20:05 +0200 Subject: [PATCH 33/34] Update shapes.rst --- docs/source/examples/shapes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/examples/shapes.rst b/docs/source/examples/shapes.rst index 2c362cd883..d7057b41c1 100644 --- a/docs/source/examples/shapes.rst +++ b/docs/source/examples/shapes.rst @@ -1,4 +1,4 @@ -Shapes +Shapes & Images ================================= .. manim:: Example1Shape From 82aea6b32d4f468b29fe54cd9ac8a324637678af Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Fri, 2 Oct 2020 15:26:57 +0200 Subject: [PATCH 34/34] Update plots.rst --- docs/source/examples/plots.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/source/examples/plots.rst b/docs/source/examples/plots.rst index 10b120869c..2d5dc4ea7c 100644 --- a/docs/source/examples/plots.rst +++ b/docs/source/examples/plots.rst @@ -160,15 +160,13 @@ Examples to illustrate the use of :class:`.GraphScene` in manim. self.add(l1, l2, l3) -The following example illustrates how to draw parametric function plots, which does not use `GraphScene` - -.. manim:: ParamFunc1 +.. manim:: ParametricFunctionWithoutGraphScene :save_last_frame: - class ParamFunc1(Scene): + class ParametricFunctionWithoutGraphScene(Scene): def func(self, t): return np.array((np.sin(2 * t), np.sin(3 * t), 0)) def construct(self): func = ParametricFunction(self.func, t_max = TAU, fill_opacity=0).set_color(RED) - self.add(func.scale(3)) \ No newline at end of file + self.add(func.scale(3))