From 6277ecee4ea49d7c7cd8e22c71b116bd35832a9b Mon Sep 17 00:00:00 2001 From: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Date: Wed, 29 Jul 2026 01:43:52 -0400 Subject: [PATCH] Road name update --- selfdrive/ui/onroad/hud_renderer.py | 4 ++-- .../onroad/starpilot/starpilot_onroad_view.py | 20 +++++++------------ system/ui/lib/text_measure.py | 6 ++++++ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/selfdrive/ui/onroad/hud_renderer.py b/selfdrive/ui/onroad/hud_renderer.py index 2cc3b5281..aed55ee59 100644 --- a/selfdrive/ui/onroad/hud_renderer.py +++ b/selfdrive/ui/onroad/hud_renderer.py @@ -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)) diff --git a/selfdrive/ui/onroad/starpilot/starpilot_onroad_view.py b/selfdrive/ui/onroad/starpilot/starpilot_onroad_view.py index 2392a913a..f38320724 100644 --- a/selfdrive/ui/onroad/starpilot/starpilot_onroad_view.py +++ b/selfdrive/ui/onroad/starpilot/starpilot_onroad_view.py @@ -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)) diff --git a/system/ui/lib/text_measure.py b/system/ui/lib/text_measure.py index dee4b419f..43cfbe883 100644 --- a/system/ui/lib/text_measure.py +++ b/system/ui/lib/text_measure.py @@ -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)