Skip to content

Fix Surface.draw_texture (#1705) #1769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions arcade/gui/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,15 @@ def draw_texture(
width: float,
height: float,
tex: Union[Texture, NinePatchTexture],
angle=0,
angle: float = 0.0,
alpha: int = 255,
):
if isinstance(tex, NinePatchTexture):
if x != 0 or y != 0:
raise ValueError("Ninepatch does not support a position != (0,0) yet")
if angle != 0.0:
raise NotImplementedError(f"Ninepatch does not support an angle != 0 yet, but got {angle}")

if x != 0 or y != 0:
raise ValueError("Ninepatch does not support a angle != 0 yet")

if x != 0 or y != 0:
raise ValueError("Ninepatch does not support a alpha != 255 yet")
if alpha != 255:
raise NotImplementedError(f"Ninepatch does not support an alpha != 255 yet, but got {alpha}")

tex.draw_sized(size=(width, height))
else:
Expand Down
33 changes: 33 additions & 0 deletions tests/unit/gui/test_surface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytest

from arcade import load_texture
from arcade.gui import Surface, NinePatchTexture


def test_surface_draw_texture_raises_not_implemented_error_on_unsupported_values(window):
ninepatch_tx = NinePatchTexture(
left=5,
right=5,
top=5,
bottom=5,
texture=load_texture(
":resources:gui_basic_assets/window/dark_blue_gray_panel.png"
))
surface = Surface(size=(100, 100))

def keywords_only(**kwargs):
surface.draw_texture(0, 0, 20, 20, ninepatch_tx, **kwargs)

with pytest.raises(NotImplementedError):
keywords_only(alpha=128)

with pytest.raises(NotImplementedError):
keywords_only(angle=30.0)

with pytest.raises(NotImplementedError):
keywords_only(alpha=10, angle=30.0)