Skip to content

Commit 2ba0d48

Browse files
fix(cli): resize only on fullscreen (#12)
* fix(cli): resize only on fullscreen Closes #10 * [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>
1 parent 5f73059 commit 2ba0d48

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

manim_slides/present.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from .defaults import CONFIG_PATH, FOLDER_PATH
1919
from .slide import reverse_video_path
2020

21+
WINDOW_NAME = "Manim Slides"
22+
2123

2224
@unique
2325
class State(IntEnum):
@@ -186,6 +188,8 @@ def __init__(
186188
self.start_paused = start_paused
187189
self.config = config
188190
self.skip_all = skip_all
191+
self.fullscreen = fullscreen
192+
self.is_windows = platform.system() == "Windows"
189193

190194
self.state = State.PLAYING
191195
self.lastframe = None
@@ -194,16 +198,16 @@ def __init__(
194198
self.lag = 0
195199
self.last_time = now()
196200

197-
if platform.system() == "Windows":
201+
if self.is_windows:
198202
user32 = ctypes.windll.user32
199203
self.screen_width, self.screen_height = user32.GetSystemMetrics(
200204
0
201205
), user32.GetSystemMetrics(1)
202206

203-
if fullscreen:
204-
cv2.namedWindow("Video", cv2.WND_PROP_FULLSCREEN)
207+
if self.fullscreen:
208+
cv2.namedWindow(WINDOW_NAME, cv2.WND_PROP_FULLSCREEN)
205209
cv2.setWindowProperty(
206-
"Video", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN
210+
WINDOW_NAME, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN
207211
)
208212

209213
def resize_frame_to_screen(self, frame: np.ndarray):
@@ -245,10 +249,10 @@ def show_video(self):
245249

246250
frame = self.lastframe
247251

248-
if platform.system() == "Windows":
252+
if self.is_windows and self.fullscreen:
249253
frame = self.resize_frame_to_screen(frame)
250254

251-
cv2.imshow("Video", frame)
255+
cv2.imshow(WINDOW_NAME, frame)
252256

253257
def show_info(self):
254258
info = np.zeros((130, 420), np.uint8)
@@ -284,7 +288,7 @@ def show_info(self):
284288
*font_args,
285289
)
286290

287-
cv2.imshow("Info", info)
291+
cv2.imshow(f"{WINDOW_NAME}: Info", info)
288292

289293
def handle_key(self):
290294
sleep_time = math.ceil(1000 / self.current_presentation.fps)

0 commit comments

Comments
 (0)