mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-20 03:57:38 +08:00
Solves #4
This commit is contained in:
@ -7,13 +7,28 @@ import math
|
|||||||
import time
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
import platform
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
QUIT_KEY = ord("q")
|
@classmethod
|
||||||
CONTINUE_KEY = 83 #right arrow
|
def init(cls):
|
||||||
BACK_KEY = 81 #left arrow
|
if platform.system() == "Windows":
|
||||||
REWIND_KEY = ord("r")
|
cls.QUIT_KEY = ord("q")
|
||||||
PLAYPAUSE_KEY = 32 #spacebar
|
cls.CONTINUE_KEY = 2555904 #right arrow
|
||||||
|
cls.BACK_KEY = 2424832 #left arrow
|
||||||
|
cls.REWIND_KEY = ord("r")
|
||||||
|
cls.PLAYPAUSE_KEY = 32 #spacebar
|
||||||
|
else:
|
||||||
|
cls.QUIT_KEY = ord("q")
|
||||||
|
cls.CONTINUE_KEY = 65363 #right arrow
|
||||||
|
cls.BACK_KEY = 65361 #left arrow
|
||||||
|
cls.REWIND_KEY = ord("r")
|
||||||
|
cls.PLAYPAUSE_KEY = 32 #spacebar
|
||||||
|
|
||||||
|
if os.path.exists(os.path.join(os.getcwd(), "./manim-presentation.json")):
|
||||||
|
json_config = json.load(open(os.path.join(os.getcwd(), "./manim-presentation.json"), "r"))
|
||||||
|
for key, value in json_config.items():
|
||||||
|
setattr(cls, key, value)
|
||||||
|
|
||||||
class State(Enum):
|
class State(Enum):
|
||||||
PLAYING = 0
|
PLAYING = 0
|
||||||
@ -224,7 +239,7 @@ class Display:
|
|||||||
|
|
||||||
def handle_key(self):
|
def handle_key(self):
|
||||||
sleep_time = math.ceil(1000/self.current_presentation.fps)
|
sleep_time = math.ceil(1000/self.current_presentation.fps)
|
||||||
key = cv2.waitKey(fix_time(sleep_time - self.lag)) & 0xFF
|
key = cv2.waitKeyEx(fix_time(sleep_time - self.lag))
|
||||||
|
|
||||||
if key == Config.QUIT_KEY:
|
if key == Config.QUIT_KEY:
|
||||||
self.quit()
|
self.quit()
|
||||||
@ -266,6 +281,9 @@ def main():
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
args.folder = os.path.normcase(args.folder)
|
args.folder = os.path.normcase(args.folder)
|
||||||
|
|
||||||
|
Config.init()
|
||||||
|
|
||||||
presentations = list()
|
presentations = list()
|
||||||
for scene in args.scenes:
|
for scene in args.scenes:
|
||||||
config_file = os.path.join(args.folder, f"{scene}.json")
|
config_file = os.path.join(args.folder, f"{scene}.json")
|
||||||
|
Reference in New Issue
Block a user