From 6e5f12bc47642e6a8f669d3b7f70bb952b3d52f3 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Tue, 22 Apr 2025 14:16:08 +0100 Subject: [PATCH] ui(raylib): reduce spinner rotation artifact A visual artifact (white pixel fringe) appeared on the edge of the rotating spinner track texture, likely due to RGB color bleed during bilinear filtering in Raylib. Pre-multiplying the alpha channel of the spinner track image using `rl.image_alpha_premultiply` significantly reduces the visibility of the artifact. --- system/ui/lib/application.py | 3 ++- system/ui/spinner.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/system/ui/lib/application.py b/system/ui/lib/application.py index 470396bbc7..319123eb19 100644 --- a/system/ui/lib/application.py +++ b/system/ui/lib/application.py @@ -50,9 +50,10 @@ class GuiApplication: self._set_styles() self._load_fonts() - def load_texture_from_image(self, file_name: str, width: int, height: int): + def load_texture_from_image(self, file_name: str, width: int, height: int, alpha_premultiply = False): """Load and resize a texture, storing it for later automatic unloading.""" image = rl.load_image(file_name) + if alpha_premultiply: rl.image_alpha_premultiply(image) rl.image_resize(image, width, height) texture = rl.load_texture_from_image(image) # Set texture filtering to smooth the result diff --git a/system/ui/spinner.py b/system/ui/spinner.py index adfb604de9..f3724cbd1e 100755 --- a/system/ui/spinner.py +++ b/system/ui/spinner.py @@ -23,7 +23,8 @@ def clamp(value, min_value, max_value): class Spinner: def __init__(self): self._comma_texture = gui_app.load_texture_from_image(os.path.join(BASEDIR, "selfdrive/assets/img_spinner_comma.png"), TEXTURE_SIZE, TEXTURE_SIZE) - self._spinner_texture = gui_app.load_texture_from_image(os.path.join(BASEDIR, "selfdrive/assets/img_spinner_track.png"), TEXTURE_SIZE, TEXTURE_SIZE) + self._spinner_texture = gui_app.load_texture_from_image(os.path.join(BASEDIR, "selfdrive/assets/img_spinner_track.png"), TEXTURE_SIZE, TEXTURE_SIZE, + alpha_premultiply=True) self._rotation = 0.0 self._text: str = "" self._progress: int | None = None