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

Python超人-宇宙模拟器

上级 3d042f44
......@@ -409,7 +409,7 @@ def create_3d_card(left=-.885, top=0.495, width=0.02, height=0.02):
return panel
def create_text_panel(width=0.35, height=.5):
def create_text_panel(width=0.35, height=.5, font=None):
# 创建一个 Panel 组件
from ursina import Text, Panel, color, camera, Vec3, window
from simulators.ursina.ursina_config import UrsinaConfig
......@@ -426,14 +426,18 @@ def create_text_panel(width=0.35, height=.5):
position=(-.49 * aspect_ratio, 0.3, 0),
alpha=0.5
)
if font is None:
font = UrsinaConfig.CN_FONT
else:
from common.func import find_file
font = find_file(f"fonts/{font}", UrsinaConfig.CN_FONT)
# 创建一个 Text 组件用于显示消息
text = Text(
parent=panel,
text='',
origin=(-.5, .5, -.5),
scale=(height * 5, width * 5),
font=UrsinaConfig.CN_FONT,
font=font,
# background=True,
# background_color=color.clear
)
......
......@@ -136,6 +136,7 @@ class HalleyCometSim(HalleyCometSimBase):
label = create_label(trail, label=year, pos=_pos,
label_color=label_color,
font="DroidSansFallback.ttf",
scale=scale, alpha=1.0, background=background
)
label.set_light_off()
......@@ -369,7 +370,7 @@ class HalleyCometSim(HalleyCometSimBase):
# 创建太阳系天体的真实轨迹(太阳和哈雷彗星除外)
self.create_orbit_lines()
# 创建信息显示面板
self.text_panel = create_text_panel()
self.text_panel = create_text_panel(font="DroidSansFallback.ttf")
def on_timer_changed(self, time_data):
"""
......
......@@ -194,14 +194,19 @@ def create_arrow(height=0.5, width=0.1):
return arrow_mesh
def create_label(parent, label, pos, label_color, scale=50, alpha=1.0, background=False):
def create_label(parent, label, pos, label_color, scale=50, alpha=1.0, background=False, font=None):
if isinstance(label_color, tuple) or isinstance(label_color, list):
label_color = conv_to_vec4_color(label_color)
if alpha < 1:
label_color[3] = alpha
if font is None:
font = UrsinaConfig.CN_FONT
else:
from common.func import find_file
font = find_file(f"fonts/{font}", UrsinaConfig.CN_FONT)
text = Text(label, parent=parent, scale=scale, billboard=True, color=label_color,
position=Vec3(pos) + Vec3(1, 1, 1), alpha=alpha,
font=UrsinaConfig.CN_FONT, background=background)
font=font, background=background)
return text
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册