Compare commits

..

15 Commits

Author SHA1 Message Date
Federico Galatolo
bfcf7db26e bump to 0.1.5 2021-05-22 12:14:54 +02:00
Federico Galatolo
b6522f4756 bump version to 0.1.4 2021-05-22 12:10:05 +02:00
Federico Galatolo
4216299b39 Fix #3 2021-05-22 12:09:07 +02:00
Federico Galatolo
cc8df92596 bump version 2021-04-24 16:18:16 +02:00
Federico Galatolo
ef22141f91 safe current_slide_i increment 2021-04-24 16:16:11 +02:00
Federico Galatolo
6881e24954 fix readme typo 2021-04-24 15:50:23 +02:00
Federico Galatolo
d7d6ac610a readme update 2021-04-24 15:44:38 +02:00
Federico Galatolo
45e923a3ca bump to v0.1.2 2021-04-24 15:39:57 +02:00
Federico Galatolo
4bbc387b81 disable caching limit while rendering 2021-04-24 15:39:34 +02:00
Federico Galatolo
01882842e0 bump version 2021-04-24 15:19:22 +02:00
Federico Galatolo
574cb9c2f6 correct lag playback compensation 2021-04-24 15:18:11 +02:00
Federico Galatolo
1827699319 Next pause slide should start at the end of last loop 2021-04-24 15:14:57 +02:00
Federico Galatolo
f4ed7b1b00 run deploy pipeline only if tag 2021-04-24 14:31:14 +02:00
Federico Galatolo
3e641fa3dc fix typo 2021-04-22 22:01:01 +02:00
Federico Galatolo
abef878811 Updated readme 2021-04-22 21:59:31 +02:00
5 changed files with 30 additions and 15 deletions

View File

@@ -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 }}

View File

@@ -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)

View File

@@ -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:

View File

@@ -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)

View File

@@ -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(),