|
|
@ -189,7 +189,8 @@ class GuiApplication: |
|
|
|
|
|
|
|
|
|
|
|
self._modal_overlay = ModalOverlay(overlay=overlay, callback=callback) |
|
|
|
self._modal_overlay = ModalOverlay(overlay=overlay, callback=callback) |
|
|
|
|
|
|
|
|
|
|
|
def texture(self, asset_path: str, width: int, height: int, alpha_premultiply=False, keep_aspect_ratio=True): |
|
|
|
def texture(self, asset_path: str, width: int | None = None, height: int | None = None, |
|
|
|
|
|
|
|
alpha_premultiply=False, keep_aspect_ratio=True): |
|
|
|
cache_key = f"{asset_path}_{width}_{height}_{alpha_premultiply}{keep_aspect_ratio}" |
|
|
|
cache_key = f"{asset_path}_{width}_{height}_{alpha_premultiply}{keep_aspect_ratio}" |
|
|
|
if cache_key in self._textures: |
|
|
|
if cache_key in self._textures: |
|
|
|
return self._textures[cache_key] |
|
|
|
return self._textures[cache_key] |
|
|
@ -199,13 +200,15 @@ class GuiApplication: |
|
|
|
self._textures[cache_key] = texture_obj |
|
|
|
self._textures[cache_key] = texture_obj |
|
|
|
return texture_obj |
|
|
|
return texture_obj |
|
|
|
|
|
|
|
|
|
|
|
def _load_texture_from_image(self, image_path: str, width: int, height: int, alpha_premultiply=False, keep_aspect_ratio=True): |
|
|
|
def _load_texture_from_image(self, image_path: str, width: int | None = None, height: int | None = None, |
|
|
|
|
|
|
|
alpha_premultiply=False, keep_aspect_ratio=True): |
|
|
|
"""Load and resize a texture, storing it for later automatic unloading.""" |
|
|
|
"""Load and resize a texture, storing it for later automatic unloading.""" |
|
|
|
image = rl.load_image(image_path) |
|
|
|
image = rl.load_image(image_path) |
|
|
|
|
|
|
|
|
|
|
|
if alpha_premultiply: |
|
|
|
if alpha_premultiply: |
|
|
|
rl.image_alpha_premultiply(image) |
|
|
|
rl.image_alpha_premultiply(image) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if width is not None and height is not None: |
|
|
|
# Resize with aspect ratio preservation if requested |
|
|
|
# Resize with aspect ratio preservation if requested |
|
|
|
if keep_aspect_ratio: |
|
|
|
if keep_aspect_ratio: |
|
|
|
orig_width = image.width |
|
|
|
orig_width = image.width |
|
|
|