Skip to content

Commit 753663a

Browse files
authored
Allow SpriteList.draw_hit_boxes to accept RGB colors (#2591)
* Alter type annotation for `color` parameter in `draw_hit_boxes` * Allow `draw_hit_boxes`to take RGB colors * Formatting
1 parent add7fb0 commit 753663a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

arcade/sprite_list/sprite_list.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,12 @@
2424
cast,
2525
)
2626

27-
from arcade import (
28-
Sprite,
29-
SpriteType,
30-
get_window,
31-
gl,
32-
)
27+
from arcade import Sprite, SpriteType, get_window, gl
3328
from arcade.gl import Program, Texture2D
3429
from arcade.gl.buffer import Buffer
3530
from arcade.gl.types import BlendFunction, OpenGlFilter, PyGLenum
3631
from arcade.gl.vertex_array import Geometry
37-
from arcade.types import RGBA255, Color, RGBANormalized, RGBOrANormalized
32+
from arcade.types import RGBA255, Color, RGBANormalized, RGBOrA255, RGBOrANormalized
3833
from arcade.utils import copy_dunders_unimplemented
3934

4035
if TYPE_CHECKING:
@@ -1131,7 +1126,9 @@ def draw(
11311126
if blend_function is not None:
11321127
self.ctx.blend_func = prev_blend_func
11331128

1134-
def draw_hit_boxes(self, color: RGBA255 = (0, 0, 0, 255), line_thickness: float = 1.0) -> None:
1129+
def draw_hit_boxes(
1130+
self, color: RGBOrA255 = (0, 0, 0, 255), line_thickness: float = 1.0
1131+
) -> None:
11351132
"""
11361133
Draw all the hit boxes in this list.
11371134
@@ -1141,9 +1138,10 @@ def draw_hit_boxes(self, color: RGBA255 = (0, 0, 0, 255), line_thickness: float
11411138
color: The color of the hit boxes
11421139
line_thickness: The thickness of the lines
11431140
"""
1144-
# NOTE: Find a way to efficiently draw this
1141+
converted_color = Color.from_iterable(color)
1142+
11451143
for sprite in self.sprite_list:
1146-
sprite.draw_hit_box(color, line_thickness)
1144+
sprite.draw_hit_box(converted_color, line_thickness)
11471145

11481146
def _normalize_index_buffer(self) -> None:
11491147
"""

0 commit comments

Comments
 (0)