提交 d344eb33 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 5552d087
...@@ -306,18 +306,36 @@ def create_3d_card(left=-.885, top=0.495, width=0.02, height=0.02): ...@@ -306,18 +306,36 @@ def create_3d_card(left=-.885, top=0.495, width=0.02, height=0.02):
scale=(width, height), scale=(width, height),
position=(left, top, 0) position=(left, top, 0)
) )
panel.color = color.rgba(0, 0, 0, 1)
panel.switch_flag = 0 panel.switch_flag = 0
panel.switch_count = [0, 0]
def switch_count_inc():
num1 = panel.switch_count[1]
if num1 >= 255:
panel.switch_count[1] = 0
panel.switch_count[0] = 0
num0 = panel.switch_count[0]
if num0 >= 255:
panel.switch_count[1] += 1
else:
panel.switch_count[0] += 1
def get_switch_index():
return panel.switch_count[1] + panel.switch_count[0]
def switch_color(): def switch_color():
if panel.color == color.black: if panel.color.r == 0:
panel.color = color.white panel.color = color.rgba(255, panel.switch_count[1], panel.switch_count[0], 255)
panel.switch_flag = 1 panel.switch_flag = 1
else: else:
panel.color = color.black panel.color = color.rgba(0, panel.switch_count[1], panel.switch_count[0], 255)
panel.switch_flag = 0 panel.switch_flag = 0
switch_count_inc()
panel.switch_color = switch_color panel.switch_color = switch_color
panel.get_switch_index = get_switch_index
return panel return panel
......
...@@ -37,7 +37,7 @@ class UrsinaSimulator(Simulator): ...@@ -37,7 +37,7 @@ class UrsinaSimulator(Simulator):
def __init__(self, bodies_sys: System): def __init__(self, bodies_sys: System):
# window.borderless = False # window.borderless = False
window.title = 'universe_sim' # '宇宙模拟器' window.title = '宇宙模拟器(universe sim)' # 'universe_sim' # '宇宙模拟器'
icon = find_file("images/icon.ico") icon = find_file("images/icon.ico")
window.icon = icon window.icon = icon
self.app = Ursina() self.app = Ursina()
......
...@@ -11,7 +11,7 @@ import win32api ...@@ -11,7 +11,7 @@ import win32api
import traceback import traceback
def get_window_handle(window_name="universe_sim"): def get_window_handle(window_name="宇宙模拟器(universe sim)"):
""" """
获取模拟器窗口句柄 获取模拟器窗口句柄
@param window_name: @param window_name:
...@@ -96,13 +96,13 @@ def create_video(args, height, width): ...@@ -96,13 +96,13 @@ def create_video(args, height, width):
return video return video
# def show_image(img): def show_image(img):
# from PIL import Image from PIL import Image
# image = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) image = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
# image = Image.fromarray(image) image = Image.fromarray(image)
# print(type(image)) # 结果为<class 'PIL.JpegImagePlugin.JpegImageFile'> print(type(image)) # 结果为<class 'PIL.JpegImagePlugin.JpegImageFile'>
# print(image.size) # 结果为(822,694),这里注意Image输出的结果先显示列数,后显示行数 print(image.size) # 结果为(822,694),这里注意Image输出的结果先显示列数,后显示行数
# image.show() image.show()
if __name__ == '__main__': if __name__ == '__main__':
...@@ -118,6 +118,8 @@ if __name__ == '__main__': ...@@ -118,6 +118,8 @@ if __name__ == '__main__':
# show_image(img) # show_image(img)
video = create_video(args, img.shape[0], img.shape[1]) video = create_video(args, img.shape[0], img.shape[1])
imageNum = 0 imageNum = 0
r_frames = []
l_frames = []
print("开始录屏") print("开始录屏")
while True: while True:
img = sim_window_screen_shot() img = sim_window_screen_shot()
...@@ -125,6 +127,17 @@ if __name__ == '__main__': ...@@ -125,6 +127,17 @@ if __name__ == '__main__':
print("\n模拟器窗口已关闭,退出录屏") print("\n模拟器窗口已关闭,退出录屏")
break break
_3d_card = img[4:20, 3:20, ]
_3d_card_p = _3d_card[10, 10, ]
if _3d_card_p[2] < 100:
_3d_card_color = "b"
_3d_card_direct = "right"
r_frames.append((_3d_card_p[1]+_3d_card_p[0], img[:432, :768, ]))
else:
_3d_card_color = "w"
_3d_card_direct = "left"
l_frames.append((_3d_card_p[1]+_3d_card_p[0], img[:432, :768, ]))
# if is_blank_screen(img): # if is_blank_screen(img):
# if imageNum % args.fps == 0: # if imageNum % args.fps == 0:
# print('x', end='') # print('x', end='')
...@@ -139,9 +152,10 @@ if __name__ == '__main__': ...@@ -139,9 +152,10 @@ if __name__ == '__main__':
imageNum += 1 imageNum += 1
# frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR) # frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
if imageNum < args.fps * args.total_time: # if imageNum < args.fps * args.total_time:
# show_image(frame) # # img = img[:432,:768,]
video.write(img) # # show_image(frame)
# video.write(img)
print("视频保存中") print("视频保存中")
video.release() video.release()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册