mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 21:14:01 +08:00
support for halve in Window
This commit is contained in:
@@ -3,14 +3,17 @@ import pygame # pylint: disable=import-error
|
||||
import cv2 # pylint: disable=import-error
|
||||
|
||||
class Window():
|
||||
def __init__(self, w, h, caption="window", double=False):
|
||||
def __init__(self, w, h, caption="window", double=False, halve=False):
|
||||
self.w = w
|
||||
self.h = h
|
||||
pygame.display.init()
|
||||
pygame.display.set_caption(caption)
|
||||
self.double = double
|
||||
self.halve = halve
|
||||
if self.double:
|
||||
self.screen = pygame.display.set_mode((w*2, h*2))
|
||||
elif self.halve:
|
||||
self.screen = pygame.display.set_mode((w//2, h//2))
|
||||
else:
|
||||
self.screen = pygame.display.set_mode((w, h))
|
||||
|
||||
@@ -19,6 +22,9 @@ class Window():
|
||||
if self.double:
|
||||
out2 = cv2.resize(out, (self.w*2, self.h*2))
|
||||
pygame.surfarray.blit_array(self.screen, out2.swapaxes(0, 1))
|
||||
elif self.halve:
|
||||
out2 = cv2.resize(out, (self.w//2, self.h//2))
|
||||
pygame.surfarray.blit_array(self.screen, out2.swapaxes(0, 1))
|
||||
else:
|
||||
pygame.surfarray.blit_array(self.screen, out.swapaxes(0, 1))
|
||||
pygame.display.flip()
|
||||
|
||||
Reference in New Issue
Block a user