🚧[WIP/TEST] Model : overlayの透過処理をsetTransparencyで実装
This commit is contained in:
@@ -105,11 +105,8 @@ class UIManager:
|
||||
if self.settings['Fade_interval'] != 0:
|
||||
self.evaluateTransparencyFade(self.overlayUI, self.lastUpdate, currTime)
|
||||
|
||||
def setImage(self, img):
|
||||
self.overlayUI.setImage(img)
|
||||
|
||||
def uiUpdate(self, img):
|
||||
self.setImage(img)
|
||||
self.overlayUI.setImage(img)
|
||||
self.overlayUI.setTransparency(self.settings['Transparency'])
|
||||
self.lastUpdate = time.monotonic()
|
||||
|
||||
@@ -140,16 +137,18 @@ class UIManager:
|
||||
def setUiScaling(self, ui_scaling):
|
||||
self.overlayUI.setUiScaling(ui_scaling)
|
||||
|
||||
def setTransparency(self, transparency):
|
||||
self.settings["Transparency"] = transparency
|
||||
|
||||
class Overlay:
|
||||
def __init__(self, x, y , depth, fade_time, fade_interval, ui_scaling):
|
||||
self.initFlag = False
|
||||
def __init__(self, x, y , depth, fade_time, fade_interval, transparency, ui_scaling):
|
||||
self.initialized = False
|
||||
settings = {
|
||||
"Color": [1, 1, 1],
|
||||
"Transparency": 1,
|
||||
"Transparency": transparency,
|
||||
"Normalized_icon_X_position": x,
|
||||
"Normalized_icon_Y_position": y,
|
||||
"Icon_plane_depth": depth,
|
||||
"Normalized_icon_width": 1,
|
||||
"Fade_time": fade_time,
|
||||
"Fade_interval": fade_interval,
|
||||
"Ui_scaling": ui_scaling,
|
||||
@@ -160,7 +159,7 @@ class Overlay:
|
||||
try:
|
||||
if checkSteamvrRunning() is True:
|
||||
openvr.init(openvr.VRApplication_Overlay)
|
||||
self.initFlag = True
|
||||
self.initialized = True
|
||||
except Exception as e:
|
||||
print("Could not initialise OpenVR")
|
||||
|
||||
@@ -204,25 +203,25 @@ if __name__ == '__main__':
|
||||
overlay = Overlay()
|
||||
overlay_image = OverlayImage()
|
||||
|
||||
if overlay.initFlag is False:
|
||||
if overlay.initialized is False:
|
||||
overlay.init()
|
||||
if overlay.initFlag is True:
|
||||
if overlay.initialized is True:
|
||||
t = threadFnc(overlay.startOverlay)
|
||||
t.start()
|
||||
|
||||
time.sleep(1)
|
||||
img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "Hello,World!Goodbye", "Japanese", ui_type="sakura")
|
||||
# img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", ui_type="sakura")
|
||||
if overlay.initFlag is True:
|
||||
if overlay.initialized is True:
|
||||
overlay.uiManager.uiUpdate(img)
|
||||
time.sleep(10)
|
||||
|
||||
img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "안녕하세요, 세계!안녕", "Korean")
|
||||
if overlay.initFlag is True:
|
||||
if overlay.initialized is True:
|
||||
overlay.uiManager.uiUpdate(img)
|
||||
time.sleep(10)
|
||||
|
||||
img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "你好世界!再见", "Chinese Simplified")
|
||||
if overlay.initFlag is True:
|
||||
if overlay.initialized is True:
|
||||
overlay.uiManager.uiUpdate(img)
|
||||
time.sleep(10)
|
||||
@@ -18,8 +18,8 @@ class OverlayImage:
|
||||
"Chinese Traditional": "NotoSansTC-Regular",
|
||||
}
|
||||
|
||||
def __init__(self, opacity):
|
||||
self.opacity = int(opacity*255)
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def concatenateImagesVertically(img1: Image, img2: Image) -> Image:
|
||||
@@ -138,9 +138,6 @@ class OverlayImage:
|
||||
# img = Image.alpha_composite(background, img)
|
||||
# return img
|
||||
|
||||
def setOpacity(self, opacity):
|
||||
self.opacity = int(opacity*255)
|
||||
|
||||
def getUiSize(self):
|
||||
return {
|
||||
"width": 960,
|
||||
@@ -151,13 +148,13 @@ class OverlayImage:
|
||||
def getUiColors(self, ui_type):
|
||||
match ui_type:
|
||||
case "default":
|
||||
background_color = (41, 42, 45, self.opacity)
|
||||
background_outline_color = (41, 42, 45, self.opacity)
|
||||
text_color = (223, 223, 223, self.opacity)
|
||||
background_color = (41, 42, 45)
|
||||
background_outline_color = (41, 42, 45)
|
||||
text_color = (223, 223, 223)
|
||||
case "sakura":
|
||||
background_color = (225, 40, 30, self.opacity)
|
||||
background_outline_color = (255, 255, 255, self.opacity)
|
||||
text_color = (223, 223, 223, self.opacity)
|
||||
background_color = (225, 40, 30)
|
||||
background_outline_color = (255, 255, 255)
|
||||
text_color = (223, 223, 223)
|
||||
return {
|
||||
"background_color": background_color,
|
||||
"background_outline_color": background_outline_color,
|
||||
|
||||
Reference in New Issue
Block a user