mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-04 13:02:09 +08:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user