Skip to content

Allow SpriteList.draw_hit_boxes to accept RGB colors #2591

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
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
18 changes: 8 additions & 10 deletions arcade/sprite_list/sprite_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@
cast,
)

from arcade import (
Sprite,
SpriteType,
get_window,
gl,
)
from arcade import Sprite, SpriteType, get_window, gl
from arcade.gl import Program, Texture2D
from arcade.gl.buffer import Buffer
from arcade.gl.types import BlendFunction, OpenGlFilter, PyGLenum
from arcade.gl.vertex_array import Geometry
from arcade.types import RGBA255, Color, RGBANormalized, RGBOrANormalized
from arcade.types import RGBA255, Color, RGBANormalized, RGBOrA255, RGBOrANormalized
from arcade.utils import copy_dunders_unimplemented

if TYPE_CHECKING:
Expand Down Expand Up @@ -1131,7 +1126,9 @@ def draw(
if blend_function is not None:
self.ctx.blend_func = prev_blend_func

def draw_hit_boxes(self, color: RGBA255 = (0, 0, 0, 255), line_thickness: float = 1.0) -> None:
def draw_hit_boxes(
self, color: RGBOrA255 = (0, 0, 0, 255), line_thickness: float = 1.0
) -> None:
"""
Draw all the hit boxes in this list.

Expand All @@ -1141,9 +1138,10 @@ def draw_hit_boxes(self, color: RGBA255 = (0, 0, 0, 255), line_thickness: float
color: The color of the hit boxes
line_thickness: The thickness of the lines
"""
# NOTE: Find a way to efficiently draw this
converted_color = Color.from_iterable(color)

for sprite in self.sprite_list:
sprite.draw_hit_box(color, line_thickness)
sprite.draw_hit_box(converted_color, line_thickness)

def _normalize_index_buffer(self) -> None:
"""
Expand Down
Loading