mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-22 04:56:24 +08:00
chore(lib): some fixes before new release
This commit is contained in:
@ -65,7 +65,7 @@ An alternative way to install Manim Slides is to clone the git repository, and i
|
|||||||
<!-- start usage -->
|
<!-- start usage -->
|
||||||
|
|
||||||
Using Manim Slides is a two-step process:
|
Using Manim Slides is a two-step process:
|
||||||
1. Render animations using `Slide` (resp. `ThreeDSlide`) as a base class instead of `Scene` (resp. `ThreeDScene`), and add calls to `self.pause()` everytime you want to create a new slide.
|
1. Render animations using `Slide` (resp. `ThreeDSlide`) as a base class instead of `Scene` (resp. `ThreeDScene`), and add calls to `self.next_slide()` everytime you want to create a new slide.
|
||||||
2. Run `manim-slides` on rendered animations and display them like a *Power Point* presentation.
|
2. Run `manim-slides` on rendered animations and display them like a *Power Point* presentation.
|
||||||
|
|
||||||
The documentation is available [online](https://eertmans.be/manim-slides/).
|
The documentation is available [online](https://eertmans.be/manim-slides/).
|
||||||
@ -87,14 +87,14 @@ class BasicExample(Slide):
|
|||||||
dot = Dot()
|
dot = Dot()
|
||||||
|
|
||||||
self.play(GrowFromCenter(circle))
|
self.play(GrowFromCenter(circle))
|
||||||
self.pause() # Waits user to press continue to go to the next slide
|
self.next_slide() # Waits user to press continue to go to the next slide
|
||||||
|
|
||||||
self.start_loop() # Start loop
|
self.start_loop() # Start loop
|
||||||
self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
|
self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
|
||||||
self.end_loop() # This will loop until user inputs a key
|
self.end_loop() # This will loop until user inputs a key
|
||||||
|
|
||||||
self.play(dot.animate.move_to(ORIGIN))
|
self.play(dot.animate.move_to(ORIGIN))
|
||||||
self.pause() # Waits user to press continue to go to the next slide
|
self.next_slide() # Waits user to press continue to go to the next slide
|
||||||
```
|
```
|
||||||
|
|
||||||
First, render the animation files:
|
First, render the animation files:
|
||||||
|
@ -12,6 +12,8 @@ The following summarizes the different presentation features Manim Slides offers
|
|||||||
| Replay slide | Yes | No | No |
|
| Replay slide | Yes | No | No |
|
||||||
| Pause animation | Yes | No | No |
|
| Pause animation | Yes | No | No |
|
||||||
| Play slide in reverse | Yes | No | No |
|
| Play slide in reverse | Yes | No | No |
|
||||||
|
| Slide count | Yes | Yes (optional) | Yes (optional) |
|
||||||
|
| Animation count | Yes | No | No |
|
||||||
| Needs Python with Manim Slides installed | Yes | No | No |
|
| Needs Python with Manim Slides installed | Yes | No | No |
|
||||||
| Requires internet access | No | Yes | No |
|
| Requires internet access | No | Yes | No |
|
||||||
| Auto. play slides | Yes | Yes | Yes |
|
| Auto. play slides | Yes | Yes | Yes |
|
||||||
|
44
example.py
44
example.py
@ -22,14 +22,14 @@ class BasicExample(Slide):
|
|||||||
dot = Dot()
|
dot = Dot()
|
||||||
|
|
||||||
self.play(GrowFromCenter(circle))
|
self.play(GrowFromCenter(circle))
|
||||||
self.pause() # Waits user to press continue to go to the next slide
|
self.next_slide() # Waits user to press continue to go to the next slide
|
||||||
|
|
||||||
self.start_loop() # Start loop
|
self.start_loop() # Start loop
|
||||||
self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
|
self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
|
||||||
self.end_loop() # This will loop until user inputs a key
|
self.end_loop() # This will loop until user inputs a key
|
||||||
|
|
||||||
self.play(dot.animate.move_to(ORIGIN))
|
self.play(dot.animate.move_to(ORIGIN))
|
||||||
self.pause() # Waits user to press continue to go to the next slide
|
self.next_slide() # Waits user to press continue to go to the next slide
|
||||||
|
|
||||||
|
|
||||||
class TestFileTooLong(Slide):
|
class TestFileTooLong(Slide):
|
||||||
@ -47,7 +47,7 @@ class TestFileTooLong(Slide):
|
|||||||
self.play(dot.animate.move_to(direction), run_time=0.1)
|
self.play(dot.animate.move_to(direction), run_time=0.1)
|
||||||
self.play(dot.animate.move_to(ORIGIN), run_time=0.1)
|
self.play(dot.animate.move_to(ORIGIN), run_time=0.1)
|
||||||
|
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
|
|
||||||
class ConvertExample(Slide):
|
class ConvertExample(Slide):
|
||||||
@ -77,7 +77,7 @@ class ConvertExample(Slide):
|
|||||||
|
|
||||||
self.play(FadeIn(title))
|
self.play(FadeIn(title))
|
||||||
|
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
code = Code(
|
code = Code(
|
||||||
code="""from manim import *
|
code="""from manim import *
|
||||||
@ -146,10 +146,10 @@ class Example(Slide):
|
|||||||
self.add(dot)
|
self.add(dot)
|
||||||
|
|
||||||
self.play(Indicate(dot, scale_factor=2))
|
self.play(Indicate(dot, scale_factor=2))
|
||||||
self.pause()
|
self.next_slide()
|
||||||
square = Square()
|
square = Square()
|
||||||
self.play(Transform(dot, square))
|
self.play(Transform(dot, square))
|
||||||
self.pause()
|
self.next_slide()
|
||||||
self.play(Rotate(square, angle=PI/2))
|
self.play(Rotate(square, angle=PI/2))
|
||||||
""",
|
""",
|
||||||
language="python",
|
language="python",
|
||||||
@ -168,7 +168,7 @@ class Example(Slide):
|
|||||||
self.end_loop()
|
self.end_loop()
|
||||||
square = Square()
|
square = Square()
|
||||||
self.play(Transform(dot, square))
|
self.play(Transform(dot, square))
|
||||||
self.pause()
|
self.next_slide()
|
||||||
self.play(Rotate(square, angle=PI/2))
|
self.play(Rotate(square, angle=PI/2))
|
||||||
""",
|
""",
|
||||||
language="python",
|
language="python",
|
||||||
@ -195,38 +195,38 @@ class Example(Slide):
|
|||||||
|
|
||||||
self.play(FadeIn(code))
|
self.play(FadeIn(code))
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.play(FadeIn(step, shift=RIGHT))
|
self.play(FadeIn(step, shift=RIGHT))
|
||||||
self.play(Transform(code, code_step_1))
|
self.play(Transform(code, code_step_1))
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.play(Transform(step, step_2))
|
self.play(Transform(step, step_2))
|
||||||
self.play(Transform(code, code_step_2))
|
self.play(Transform(code, code_step_2))
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.play(Transform(step, step_3))
|
self.play(Transform(step, step_3))
|
||||||
self.play(Transform(code, code_step_3))
|
self.play(Transform(code, code_step_3))
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.play(Transform(step, step_4))
|
self.play(Transform(step, step_4))
|
||||||
self.play(Transform(code, code_step_4))
|
self.play(Transform(code, code_step_4))
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.play(Transform(step, step_5))
|
self.play(Transform(step, step_5))
|
||||||
self.play(Transform(code, code_step_5))
|
self.play(Transform(code, code_step_5))
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.play(Transform(step, step_6))
|
self.play(Transform(step, step_6))
|
||||||
self.play(Transform(code, code_step_6))
|
self.play(Transform(code, code_step_6))
|
||||||
self.play(code.animate.shift(UP), FadeIn(code_step_7), FadeIn(or_text))
|
self.play(code.animate.shift(UP), FadeIn(code_step_7), FadeIn(or_text))
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
watch_text = Text("Watch result on next slides!").shift(2 * DOWN).scale(0.5)
|
watch_text = Text("Watch result on next slides!").shift(2 * DOWN).scale(0.5)
|
||||||
|
|
||||||
@ -246,10 +246,10 @@ class Example(Slide):
|
|||||||
self.remove(dot)
|
self.remove(dot)
|
||||||
self.add(square)
|
self.add(square)
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
self.play(Rotate(square, angle=PI / 4))
|
self.play(Rotate(square, angle=PI / 4))
|
||||||
self.tinywait()
|
self.tinywait()
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
learn_more_text = (
|
learn_more_text = (
|
||||||
VGroup(
|
VGroup(
|
||||||
@ -281,7 +281,7 @@ if not MANIMGL:
|
|||||||
self.play(GrowFromCenter(circle))
|
self.play(GrowFromCenter(circle))
|
||||||
self.begin_ambient_camera_rotation(rate=75 * DEGREES / 4)
|
self.begin_ambient_camera_rotation(rate=75 * DEGREES / 4)
|
||||||
|
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.start_loop()
|
self.start_loop()
|
||||||
self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)
|
self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)
|
||||||
@ -291,10 +291,10 @@ if not MANIMGL:
|
|||||||
self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES)
|
self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES)
|
||||||
|
|
||||||
self.play(dot.animate.move_to(ORIGIN))
|
self.play(dot.animate.move_to(ORIGIN))
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.play(dot.animate.move_to(RIGHT * 3))
|
self.play(dot.animate.move_to(RIGHT * 3))
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.start_loop()
|
self.start_loop()
|
||||||
self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
|
self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
|
||||||
@ -330,7 +330,7 @@ else:
|
|||||||
updater = lambda m, dt: m.increment_theta((75 * DEGREES / 4) * dt)
|
updater = lambda m, dt: m.increment_theta((75 * DEGREES / 4) * dt)
|
||||||
frame.add_updater(updater)
|
frame.add_updater(updater)
|
||||||
|
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.start_loop()
|
self.start_loop()
|
||||||
self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)
|
self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)
|
||||||
@ -339,10 +339,10 @@ else:
|
|||||||
frame.remove_updater(updater)
|
frame.remove_updater(updater)
|
||||||
self.play(frame.animate.set_theta(30 * DEGREES))
|
self.play(frame.animate.set_theta(30 * DEGREES))
|
||||||
self.play(dot.animate.move_to(ORIGIN))
|
self.play(dot.animate.move_to(ORIGIN))
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.play(dot.animate.move_to(RIGHT * 3))
|
self.play(dot.animate.move_to(RIGHT * 3))
|
||||||
self.pause()
|
self.next_slide()
|
||||||
|
|
||||||
self.start_loop()
|
self.start_loop()
|
||||||
self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
|
self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
|
||||||
|
@ -389,7 +389,7 @@ class PowerPoint(Converter):
|
|||||||
|
|
||||||
# From GitHub issue comment:
|
# From GitHub issue comment:
|
||||||
# - https://github.com/scanny/python-pptx/issues/427#issuecomment-856724440
|
# - https://github.com/scanny/python-pptx/issues/427#issuecomment-856724440
|
||||||
def auto_play_media(media: pptx.shape.picture.Movie, loop: bool = False):
|
def auto_play_media(media: pptx.shapes.picture.Movie, loop: bool = False):
|
||||||
el_id = xpath(media.element, ".//p:cNvPr")[0].attrib["id"]
|
el_id = xpath(media.element, ".//p:cNvPr")[0].attrib["id"]
|
||||||
el_cnt = xpath(
|
el_cnt = xpath(
|
||||||
media.element.getparent().getparent().getparent(),
|
media.element.getparent().getparent().getparent(),
|
||||||
|
@ -151,7 +151,7 @@ class Slide(Scene): # type:ignore
|
|||||||
"""
|
"""
|
||||||
Creates a new slide with previous animations.
|
Creates a new slide with previous animations.
|
||||||
|
|
||||||
.. deprecated:: 4.9.3
|
.. deprecated:: 4.10.0
|
||||||
Use :func:`next_slide` instead.
|
Use :func:`next_slide` instead.
|
||||||
"""
|
"""
|
||||||
warn(
|
warn(
|
||||||
|
Reference in New Issue
Block a user