mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-18 11:05:54 +08:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
bfcf7db26e | |||
b6522f4756 | |||
4216299b39 | |||
cc8df92596 | |||
ef22141f91 | |||
6881e24954 | |||
d7d6ac610a | |||
45e923a3ca | |||
4bbc387b81 | |||
01882842e0 | |||
574cb9c2f6 | |||
1827699319 | |||
f4ed7b1b00 | |||
3e641fa3dc | |||
abef878811 |
2
.github/workflows/deploy-pipy.yaml
vendored
2
.github/workflows/deploy-pipy.yaml
vendored
@ -4,6 +4,7 @@ on: push
|
||||
jobs:
|
||||
build-n-publish:
|
||||
name: Build and publish to PyPI
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
@ -16,7 +17,6 @@ jobs:
|
||||
- name: Build binary wheel and a source tarball
|
||||
run: python -m build --sdist --wheel --outdir dist/ .
|
||||
- name: Publish to PyPI
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
15
README.md
15
README.md
@ -5,7 +5,7 @@ Tool for live presentations using [manim](https://www.manim.community/)
|
||||
## Install
|
||||
|
||||
```
|
||||
pip install manim_presentation opencv-python
|
||||
pip install manim-presentation opencv-python
|
||||
```
|
||||
|
||||
## Usage
|
||||
@ -20,9 +20,9 @@ class Example(Slide):
|
||||
...
|
||||
```
|
||||
|
||||
call `self.pause()` when you want to pause the playback
|
||||
call `self.pause()` when you want to pause the playback and wait for an input to continue (check the keybindings)
|
||||
|
||||
call `self.start_loop()` and `self.stop_loop()` when you want to loop some animations
|
||||
Wrap a series of animations between `self.start_loop()` and `self.stop_loop()` when you want to loop them (until input to continue)
|
||||
|
||||
```python
|
||||
from manim import *
|
||||
@ -46,6 +46,11 @@ class Example(Slide):
|
||||
self.wait()
|
||||
```
|
||||
|
||||
To start the presentation using `Scene1`, `Scene2` and so on simply run:
|
||||
|
||||
```
|
||||
manim_presentation Scene1 Scene2...
|
||||
```
|
||||
|
||||
## Default Keybindings
|
||||
|
||||
@ -78,7 +83,7 @@ virtualenv --python=python3.7 env
|
||||
Install `manim` and `manim_presentation`
|
||||
|
||||
```
|
||||
pip install manim manim_presentation opencv-python
|
||||
pip install manim manim-presentation opencv-python
|
||||
```
|
||||
|
||||
Render the example scene
|
||||
@ -95,6 +100,6 @@ manim_presentation Example
|
||||
|
||||
## Contributions and license
|
||||
|
||||
The code is released as Free Software under the [GNU/GPLv3](https://choosealicense.com/licenses/gpl-3.0/) license. Copying, adapting e republishing it is not only consent but also encouraged.
|
||||
The code is released as Free Software under the [GNU/GPLv3](https://choosealicense.com/licenses/gpl-3.0/) license. Copying, adapting and republishing it is not only consent but also encouraged.
|
||||
|
||||
For any further question feel free to reach me at [federico.galatolo@ing.unipi.it](mailto:federico.galatolo@ing.unipi.it) or on Telegram [@galatolo](https://t.me/galatolo)
|
@ -64,7 +64,7 @@ class Presentation:
|
||||
self.caps.append(cv2.VideoCapture(f))
|
||||
|
||||
def next(self):
|
||||
self.current_slide_i += 1
|
||||
self.current_slide_i = min(len(self.slides) - 1, self.current_slide_i + 1)
|
||||
self.current_animation = self.current_slide["start_animation"]
|
||||
|
||||
def prev(self):
|
||||
@ -116,6 +116,8 @@ class Display:
|
||||
self.state = State.PLAYING
|
||||
self.lastframe = None
|
||||
self.current_presentation_i = 0
|
||||
|
||||
self.lag = 0
|
||||
self.last_time = now()
|
||||
|
||||
@property
|
||||
@ -141,6 +143,8 @@ class Display:
|
||||
self.handle_key()
|
||||
|
||||
def show_video(self):
|
||||
self.lag = now() - self.last_time
|
||||
self.last_time = now()
|
||||
cv2.imshow("Video", self.lastframe)
|
||||
|
||||
def show_info(self):
|
||||
@ -186,9 +190,7 @@ class Display:
|
||||
|
||||
def handle_key(self):
|
||||
sleep_time = math.ceil(1000/self.current_presentation.fps)
|
||||
lag = now() - self.last_time
|
||||
self.last_time = now()
|
||||
key = cv2.waitKey(fix_time(sleep_time - lag)) & 0xFF
|
||||
key = cv2.waitKey(fix_time(sleep_time - self.lag)) & 0xFF
|
||||
|
||||
if key == Config.QUIT_KEY:
|
||||
self.quit()
|
||||
@ -225,9 +227,9 @@ def main():
|
||||
parser.add_argument("scenes", metavar="scenes", type=str, nargs="+", help="Scenes to present")
|
||||
parser.add_argument("--folder", type=str, default="./presentation", help="Presentation files folder")
|
||||
parser.add_argument("--start-paused", action="store_true", help="Start paused")
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
args.folder = os.path.normcase(args.folder)
|
||||
|
||||
presentations = list()
|
||||
for scene in args.scenes:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import os
|
||||
import json
|
||||
import shutil
|
||||
from manim import Scene
|
||||
from manim import Scene, config
|
||||
|
||||
class Slide(Scene):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -41,9 +41,17 @@ class Slide(Scene):
|
||||
))
|
||||
self.current_slide += 1
|
||||
self.loop_start_animation = None
|
||||
self.pause_start_animation = self.current_animation
|
||||
|
||||
def render(self, *args, **kwargs):
|
||||
# We need to disable the caching limit since we rely on intermidiate files
|
||||
max_files_cached = config["max_files_cached"]
|
||||
config["max_files_cached"] = float("inf")
|
||||
|
||||
super(Slide, self).render(*args, **kwargs)
|
||||
|
||||
config["max_files_cached"] = max_files_cached
|
||||
|
||||
if not os.path.exists(self.output_folder):
|
||||
os.mkdir(self.output_folder)
|
||||
|
||||
|
6
setup.py
6
setup.py
@ -6,11 +6,11 @@ with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "README.md")
|
||||
|
||||
setuptools.setup(
|
||||
name="manim_presentation",
|
||||
version="0.1.0",
|
||||
version="0.1.5",
|
||||
author="Federico A. Galatolo",
|
||||
author_email="federico.galatolo@ing.unipi.it",
|
||||
description="",
|
||||
url="",
|
||||
description="Tool for live presentations using manim",
|
||||
url="https://github.com/galatolofederico/manim-presentation",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
packages=setuptools.find_packages(),
|
||||
|
Reference in New Issue
Block a user