Road name update

This commit is contained in:
firestarsdog
2026-07-29 01:43:52 -04:00
parent 0078eb477c
commit 6277ecee4e
3 changed files with 15 additions and 15 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ from openpilot.selfdrive.ui.onroad.starpilot.compass import get_compass_text
from openpilot.selfdrive.ui.ui_state import ui_state, UIStatus
from openpilot.system.ui.lib.application import gui_app, FontWeight
from openpilot.system.ui.lib.multilang import tr
from openpilot.system.ui.lib.text_measure import measure_text_cached
from openpilot.system.ui.lib.text_measure import draw_text_with_shadow, measure_text_cached
from openpilot.system.ui.widgets import Widget
# Constants
@@ -201,4 +201,4 @@ class HudRenderer(Widget):
compass_font_size = 50
compass_size = measure_text_cached(self._font_bold, compass_text, compass_font_size)
compass_pos = rl.Vector2(rect.x + rect.width / 2 - compass_size.x / 2, 65 - compass_size.y / 2)
rl.draw_text_ex(self._font_bold, compass_text, compass_pos, compass_font_size, 0, rl.Color(255, 255, 255, 180))
draw_text_with_shadow(self._font_bold, compass_text, compass_pos, compass_font_size, rl.Color(255, 255, 255, 180))
@@ -21,7 +21,7 @@ from openpilot.selfdrive.ui.lib.starpilot_status import (
)
from openpilot.system.ui.lib.application import MousePos, gui_app, FontWeight
from openpilot.system.ui.lib.text_measure import measure_text_cached
from openpilot.system.ui.lib.text_measure import draw_text_with_shadow, measure_text_cached
from cereal import log
AlertSize = log.SelfdriveState.AlertSize
@@ -398,18 +398,12 @@ class StarPilotOnroadView(AugmentedRoadView):
return
font = self._font_bold
font_size = 32
font_size = 40
sz = measure_text_cached(font, road_name, font_size)
pad_x = 24
pad_y = 5
pill_w = sz.x + pad_x * 2
pill_h = font_size + pad_y * 2
cx = self._content_rect.x + self._content_rect.width / 2
by = self._content_rect.y + self._content_rect.height - pill_h - 16
pill = rl.Rectangle(cx - pill_w / 2, by, pill_w, pill_h)
rl.draw_rectangle_rounded(pill, 0.4, 8, rl.Color(0, 0, 0, 166))
rl.draw_rectangle_rounded_lines_ex(pill, 0.4, 8, 1, rl.Color(255, 255, 255, 60))
rl.draw_text_ex(font, road_name, rl.Vector2(cx - sz.x / 2, by + pad_y), font_size, 0, rl.WHITE)
text_pos = rl.Vector2(
round(cx - sz.x / 2),
round(self._content_rect.y + self._content_rect.height - sz.y - 5),
)
draw_text_with_shadow(font, road_name, text_pos, font_size, rl.Color(255, 255, 255, 180))
+6
View File
@@ -5,6 +5,12 @@ from openpilot.system.ui.lib.emoji import find_emoji
_cache: dict[int, rl.Vector2] = {}
def draw_text_with_shadow(font: rl.Font, text: str, pos: rl.Vector2, font_size: int, color: rl.Color,
shadow_alpha: int = 120) -> None:
rl.draw_text_ex(font, text, rl.Vector2(pos.x + 1, pos.y + 1), font_size, 0, rl.Color(0, 0, 0, shadow_alpha))
rl.draw_text_ex(font, text, pos, font_size, 0, color)
def measure_text_cached(font: rl.Font, text: str, font_size: int, spacing: float = 0) -> rl.Vector2:
"""Caches text measurements to avoid redundant calculations."""
font = font_fallback(font)