mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-21 20:46:01 +08:00
feat(lib): add Slide.next_section
method (#295)
* feat(lib): add `Slide.next_section` method * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -43,6 +43,9 @@ In an effort to better document changes, this CHANGELOG document is now created.
|
|||||||
- Added `loop` option to `Slide`'s `next_slide` method.
|
- Added `loop` option to `Slide`'s `next_slide` method.
|
||||||
Calling `next_slide` will never fail anymore.
|
Calling `next_slide` will never fail anymore.
|
||||||
[#294](https://github.com/jeertmans/manim-slides/pull/294)
|
[#294](https://github.com/jeertmans/manim-slides/pull/294)
|
||||||
|
- Added `Slide.next_section` for compatibility with `manim`'s
|
||||||
|
`Scene.next_section` method.
|
||||||
|
[#295](https://github.com/jeertmans/manim-slides/pull/295)
|
||||||
|
|
||||||
(v5-changed)=
|
(v5-changed)=
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -15,6 +15,7 @@ use, not the methods used internally when rendering.
|
|||||||
canvas,
|
canvas,
|
||||||
canvas_mobjects,
|
canvas_mobjects,
|
||||||
mobjects_without_canvas,
|
mobjects_without_canvas,
|
||||||
|
next_section,
|
||||||
next_slide,
|
next_slide,
|
||||||
remove_from_canvas,
|
remove_from_canvas,
|
||||||
wait_time_between_slides,
|
wait_time_between_slides,
|
||||||
|
@ -252,7 +252,7 @@ class BaseSlide:
|
|||||||
super().play(*args, **kwargs) # type: ignore[misc]
|
super().play(*args, **kwargs) # type: ignore[misc]
|
||||||
self._current_animation += 1
|
self._current_animation += 1
|
||||||
|
|
||||||
def next_slide(self, loop: bool = False) -> None:
|
def next_slide(self, *, loop: bool = False, **kwargs: Any) -> None:
|
||||||
"""
|
"""
|
||||||
Create a new slide with previous animations, and setup options
|
Create a new slide with previous animations, and setup options
|
||||||
for the next slide.
|
for the next slide.
|
||||||
@ -260,8 +260,16 @@ class BaseSlide:
|
|||||||
This usually means that the user will need to press some key before the
|
This usually means that the user will need to press some key before the
|
||||||
next slide is played. By default, this is the right arrow key.
|
next slide is played. By default, this is the right arrow key.
|
||||||
|
|
||||||
|
:param args:
|
||||||
|
Positional arguments to be passed to
|
||||||
|
:meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`,
|
||||||
|
or ignored if `manimlib` API is used.
|
||||||
:param loop:
|
:param loop:
|
||||||
If set, next slide will be looping.
|
If set, next slide will be looping.
|
||||||
|
:param kwargs:
|
||||||
|
Keyword arguments to be passed to
|
||||||
|
:meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`,
|
||||||
|
or ignored if `manimlib` API is used.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
@ -273,6 +281,11 @@ class BaseSlide:
|
|||||||
When rendered with RevealJS, loops cannot be in the first nor
|
When rendered with RevealJS, loops cannot be in the first nor
|
||||||
the last slide.
|
the last slide.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
When using ``manim`` API, this method will also call
|
||||||
|
:meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`.
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
The following contains 3 slides:
|
The following contains 3 slides:
|
||||||
|
@ -64,6 +64,25 @@ class Slide(BaseSlide, Scene): # type: ignore[misc]
|
|||||||
def _start_at_animation_number(self) -> Optional[int]:
|
def _start_at_animation_number(self) -> Optional[int]:
|
||||||
return config["from_animation_number"] # type: ignore
|
return config["from_animation_number"] # type: ignore
|
||||||
|
|
||||||
|
def next_section(self, *args: Any, **kwargs: Any) -> None:
|
||||||
|
"""
|
||||||
|
Alias to :meth:`next_slide`.
|
||||||
|
|
||||||
|
:param args:
|
||||||
|
Positional arguments to be passed to :meth:`next_slide`.
|
||||||
|
:param kwargs:
|
||||||
|
Keyword arguments to be passed to :meth:`next_slide`.
|
||||||
|
|
||||||
|
.. attention::
|
||||||
|
|
||||||
|
This method is only available when using ``manim`` API.
|
||||||
|
"""
|
||||||
|
self.next_slide(*args, **kwargs)
|
||||||
|
|
||||||
|
def next_slide(self, *args: Any, loop: bool = False, **kwargs: Any) -> None:
|
||||||
|
Scene.next_section(self, *args, **kwargs)
|
||||||
|
BaseSlide.next_slide(self, loop=loop)
|
||||||
|
|
||||||
def render(self, *args: Any, **kwargs: Any) -> None:
|
def render(self, *args: Any, **kwargs: Any) -> None:
|
||||||
"""MANIM render."""
|
"""MANIM render."""
|
||||||
# We need to disable the caching limit since we rely on intermediate files
|
# We need to disable the caching limit since we rely on intermediate files
|
||||||
|
Reference in New Issue
Block a user