ui(raylib): reduce spinner rotation artifact (#35048)

* ui(raylib): reduce spinner rotation artifact

A visual artifact (white pixels) 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.

* lint
pull/35049/head
Cameron Clough 3 days ago committed by GitHub
parent 8cefc00a6e
commit 23524e2038
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      system/ui/lib/application.py
  2. 3
      system/ui/spinner.py

@ -50,9 +50,11 @@ 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

@ -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

Loading…
Cancel
Save